Topic "Automation Script"

Author Message
bainwave
[View user's profile]

Joined: 2013-07-05
Posts: 3
Location: India
Hi Experts,
Am new to scripting, need your help in building an script, which can run in Task Scheduler.
Here goes my scenario...
I have Linux box (cent OS), in which every day *.txt files will be created in the following format
"20130813-091152-1376365312.882813.txt". Every day roughly 600 files will be created.
I have an other box with Windows OS(Server 2008) with huge space in d drive.
My requirement is as follows...
1. Should Create a sub-folder and name it in date format (yyyymmdd)on windows box.
2. copy all the related data, basing on the date stamp from Linux to the newly created folder
3. Delete all the data basing on the date stamp, from the Linux box.
4. Like wise everyday a new folder shall be created and all the data should be moved from Linux to windows box.
5. Finally, the trick is, this script should work only on condition, where Today minus 15 Days is the condition. Means it should start working only on the files, which were 15 days back from today, leaving all these 15 days on the Linux box.

I tried different combinations of the scripting, available in this forum, but in vain.

I need your help in building a script
Hope am clear in asking.

Thanks in advance.
Advertisements
martin
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 25034
Location: Prague, Czechia
Shows us what have you tried.
_________________
Martin Prikryl
bainwave
[View user's profile]

Joined: 2013-07-05
Posts: 3
Location: India
// Function to figure out the date of the previous business day
// in the format YYYYMMDD including place holding zeros.
function PreviousBizDay() {
function D2( val ) {
return ( ( val < 10 ) ? '0' : '' ) + val;
}
var today = new Date();
today.setDate( today.getDate() - 1 ); // Yesterday...
while ( ( today.getDay() < 1 ) || ( today.getDay() > 5 ) ) {
today.setDate( today.getDate() - 1 ); // Previous day
}
return today.getFullYear() + D2( today.getMonth() + 1 ) + D2( today.getDate() )
}
// Local path to download to (MUST keep trailing slashes)
var LOCALPATH = "d:\\logs\\";
// Remote path to search in (MUST keep trailing slash)
var REMOTEPATH = "/var/spool/monitor";
// Session to connect to
var SESSION = "root:xxxxxxx@10.10.10.10";
// Path to winscp.com (MUST keep trailing slashes)
var WINSCP = "c:\\program files\\winscp\\winscp.com";
var filesys = WScript.CreateObject("Scripting.FileSystemObject");
var shell = WScript.CreateObject("WScript.Shell");
var FILE1 = "file." + PreviousBizDay() + ".".txt";
var exec;

// Run WINSCP and download the 3 files, then exit
exec = shell.Exec("\"" + WINSCP + "\"");
exec.StdIn.Write(
"option batch abort\n" +
"option confirm off\n" +
"open \"" + SESSION + "\"\n" +
"get \"" + REMOTEPATH + FILE1 + "\" \"" + LOCALPATH + "\"\n" +
"exit\n");
bainwave
[View user's profile]

Joined: 2013-07-05
Posts: 3
Location: India
Hi Experts,
Need your advise.
martin
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 25034
Location: Prague, Czechia
bainwave wrote:
Hi Experts,
Need your advise.

Sorry, but this is not general programming forum. Consider asking on http://stackoverflow.com/. Post a link here, if you do.
_________________
Martin Prikryl
Advertisements

You can post new topics in this forum






Search Site

What is WinSCP?

It is award-winning SFTP client, SCP client, FTPS client and FTP client integrated into one software program for file transfer to FTP server or secure SFTP server. [More]

And it's free!

Donate

About donations

$9   $19   $49   $99

About donations

Recommend

WinSCP Privacy Policy

WinSCP License