Protocol ftp:// and scripting

Advertisement

MPV
Joined:
Posts:
1

Protocol ftp:// and scripting

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 doesn't require the ftp:// and passive mode working without a problem. I have tried several approaches, all of which don't 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 doesn't 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 doesn't 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?

Reply with quote

Advertisement

Eric_AZ
Joined:
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

Reply with quote

Eric_AZ
Joined:
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

Reply with quote

martin
Site Admin
martin avatar

-script=C:\Program Files\WinSCP\script.txt
Make sure to enclose the path into double-quotes as it contains a space

Reply with quote

Advertisement

Eric_AZ
Joined:
Posts:
4
Location:
U.S.

martin wrote:

-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.

Reply with quote

Eric_AZ
Joined:
Posts:
4
Location:
U.S.

Eric_AZ wrote:

martin wrote:

-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!

Reply with quote

Advertisement

You can post new topics in this forum