Topic "Protocol ftp:// and scripting"

Author Message
MPV
[View user's profile]

Joined: 2009-08-28
Posts: 1
What is the correct way to run scripting when protocol ftp:// is required?

I am running Version 4.2.1 (Build 428) and having problems running a script while being required to use ftp:// and passive mode. The process needs to be automated and run within a SSIS package. I have another FTP process defined with SSIS using WinSCP that doesnt require the ftp:// and passive mode working without a problem. I have tried several approaches, all of which dont seem to work. The only way I have been successful has been by manually executing the FTP process. For security reasons, protocol ftp:// ignores any scripting so the following SSIS package connects correctly but doesnt execute the script:

Executable: \\server\WinSCP.exe
Arguments: ftp://userID:pwd@ABC.com :21 /passive /option binary /script=""FTPScript.txt

The second option that was tried was to try the OPEN command inside of a script. This option doesnt make a connection on the destination site:

SSIS package
Executable: \\server\WinSCP.exe
Arguments: /script=FTPScript.txt


FTPScript.txt looks like:
Open ftp://userID:pwd@ABC.com :21 /passive /option binary

option batch abort
option confirm off

cscript PutFile.vbs

PutFile.vbs contains the following:
Dim objShell, intRtn, sMonth, sDay, sYear
sMonth = cstr(MONTH(Date))
sDay = cstr(DAY(Date))
sYear = cstr(YEAR(Date))

Set objShell = WScript.CreateObject ("WSCript.shell")

command = "put D:\PaymentExtract\101003927_" & sMonth & sDay & sYear & "_file.txt"

intRtn = objShell.run (command)

Set objShell = Nothing


The other option I tried was using a BAT file that executed a script using cscript:

FTPFile.bat contains 1 line of code that reads: cscript PutFile.vbs

PutFile.vbs looks like the following:
Dim objShell1, objShell2, intRtn1, intRtn2, cmd1, cmd2, sMonth, sDay, sYear

sMonth = cstr(MONTH(Date))
sDay = cstr(DAY(Date))
sYear = cstr(YEAR(Date))

cmd1 = "\\server\path\winscp.exe ftp://userID:pwd@ABC.com :21 /passive /option binary /
cmd2 = "Put D:\PaymentExtract\101003927_" & SMonth & sDay & sYear & "_file.txt"


Set objShell1 = WScript.CreateObject ("WSCript.shell")
intRtn1 = objShell1.run (cmd1)
Set objShell1 = Nothing

Set objShell2 = WScript.CreateObject ("WSCript.shell")
intRtn2 = objShell2.run (cmd2)
Set objShell2 = Nothing

I have executed the BAT process at a cmd prompt and received and error message that it states: PutFile.vbs (30,1) (Null): The system cannot find the file specified. Line (30,1) represents the PUT command.

Does anyone have any ideas?
Advertisements
martin
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 25034
Location: Prague, Czechia
Remove all command-line arguments, except the /script and in the script do:
open ftp://userID:pwd@ABC.com:21 -passive
option transfer binary
_________________
Martin Prikryl
Eric_AZ
[View user's profile]

Joined: 2010-05-18
Posts: 4
Location: U.S.
Thank you for this excellent software!

Like the original poster, I have tried many things and still can't seem to get a connection running through SSIS. I have read all the documentation, and many forum posts before asking. Once I have a functional script and SSIS package, I promise to post my work in a new thread for other users.

Here is where I am at:

I have a fully functional connection in the WInSCP GUI. I am trying to make use of this saved connection as a script call in SSIS. I believe it is probably just a syntax problem, which once resolved, will allow me to proceed with using the FTP commands I want.

Connection attributes:

ftp.mysite.com Port 22
protocol: FTP SSL/TLS Implicit encryption

Storage has been changed to .ini. I tried registry also.

SSIS is set to ignore return codes.

SSIS package calls:

SSIS Executable:
C:\Program Files\WinSCP\WinSCP.exe

(When ran with no script argument, SSIS starts the WinSCP GUI.)

SSIS Arguments:
-script=C:\Program Files\WinSCP\script.txt

Contents of script (I have tried numerous script changes):

option batch abort
option confirm off
open USER@ftp.mysite.com (...this is the name of the saved connection which is working well in the GUI)

I have tried both levels of logging. When running with a script argument, no logs are created. When launching the GUI and using my saved connection, logging works fine.

Please help me. If I can get this figured out I will post an exact example back to the forums of what gave me success to help other users.

Thank you,
Eric
Eric_AZ
[View user's profile]

Joined: 2010-05-18
Posts: 4
Location: U.S.
Since my last post, from the SSIS argument, I have been able to make a successful connection with the following instead of the script switch:

/command "open savedsessionname" "option confirm off"

I would really like to use a script file though, so I would very much appreciate the help re: my script test above.

Thank you,
Eric
martin
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 25034
Location: Prague, Czechia
Quote:
-script=C:\Program Files\WinSCP\script.txt

Make sure to enclose the path into double-quotes as it contains a space
_________________
Martin Prikryl
Eric_AZ
[View user's profile]

Joined: 2010-05-18
Posts: 4
Location: U.S.
prikryl wrote:
Quote:
-script=C:\Program Files\WinSCP\script.txt

Make sure to enclose the path into double-quotes as it contains a space


Excellent, thank you, I'll give that a try and report back.
Eric_AZ
[View user's profile]

Joined: 2010-05-18
Posts: 4
Location: U.S.
Eric_AZ wrote:
prikryl wrote:
Quote:
-script=C:\Program Files\WinSCP\script.txt

Make sure to enclose the path into double-quotes as it contains a space


Excellent, thank you, I'll give that a try and report back.


That fixed it, thank you! I will now continue to build my script file. Much appreciated!
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