// Local path to download to (keep trailing slash)
var LOCALPATH = "\\D:\SCW_Reports";
// Remote path to download from (keep trailing slash)
var REMOTEPATH = "/cd/MPesa";
// File to download
var FILE = "winscp421.exe";
// Session to connect to
var SESSION = "MPesa@OXIVMP@
[email protected]";
// Path to winscp.com
var WINSCP = "C:\Program Files (x86)\WinSCP\WinSCP.com";
// helper function to pad zeroes to the left of number
function pad(n, len)
{
var s = n.toString();
while (s.length < len)
{
s = '0' + s;
}
return s;
}
var date = new Date();
// format timestamp
var stamp =
pad(date.getFullYear(), 4) +
pad(date.getMonth(), 2) +
pad(date.getDate(), 2) ;
var shell = WScript.CreateObject("WScript.Shell");
// run winscp to download the file into timestamped-filename
exec = shell.Exec("\"" + WINSCP + "\"");
exec.StdIn.Write(
"option batch abort\n" +
"open \"" + SESSION + "\"\n" +
"Put \"" + REMOTEPATH + FILE + "\" \"" + LOCALPATH + FILE + "." + stamp + "\"\n" +
"exit\n");
// wait until the script finishes
while (exec.Status == 0)
{
WScript.Sleep(100);
WScript.Echo(exec.StdOut.ReadAll());
}
I ran the above scrpt , output was not showing.