How to Put the date & time format files into SFTP server?

Advertisement

limitha
Joined:
Posts:
8

How to Put the date & time format files into SFTP server?

I am doing SFTP task in SSIS.
i am using the following script.

option batch abort
# Disable overwrite confirmations that conflict with the previous
option confirm off
# Connect using a password
# open sftp://MPesa:OXIVMP@123@Mysftpserver:22
# Connect
open sftp://MPesa:OXIVMP@123@MySftpserver:22
# Change remote directory
cd /MPesa/
# Force binary mode transfer
option transfer binary
# Download file to the local directory d:\
put D:\SCW_Reports\Oxigen.txt
# Disconnect
close
exit

The above code working fine.
How to put the Oxigen_03052013.txt format files.

Reply with quote

Advertisement

limitha
Joined:
Posts:
8

Could you please send me any modifications in below script.

// 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@123@127.10.16.223";
// 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.

Reply with quote

limitha
Joined:
Posts:
8

Whenever i run the below script i am getting the error.

Error Code: 0 Error Source= Microsoft JScript runtime error Error Description: 'WScript' is undefined Error on Line 30.[/size]


// 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@123@127.10.16.223";
// 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());
}

Reply with quote

martin
Site Admin
martin avatar
Joined:
Posts:
27,226
Location:
Prague, Czechia

Re: Whenever i run the below script i am getting the error.

limitha wrote:

Error Code: 0 Error Source= Microsoft JScript runtime error Error Description: 'WScript' is undefined Error on Line 30.
How are you running the script?
_________________
Martin Prikryl

Reply with quote

martin
Site Admin
martin avatar
Joined:
Posts:
27,226
Location:
Prague, Czechia

Re: I ran the script through SQL Agent .

limitha wrote:

I ran the script through SQL agent.
Ok, can you be more specific? Like command-line you used. Do you use wscript or cscript or somethine else?
_________________
Martin Prikryl

Reply with quote

cdmiss
Joined:
Posts:
1

Private keys in sFTP

Hi

I am searching the location/path/file where private keys are stored in sFTP. I mean the private key of encrypted packages.
Does anyone know how i can find some kind of information like this

Thanks a lot

Reply with quote

Advertisement

You can post new topics in this forum