SFTP works in Command interface, not automatic.

Advertisement

kmideas
Joined:
Posts:
4

SFTP works in Command interface, not automatic.

I'm trying to automate the FTP using a command line in Scheduled Tasks, Windows 7 - 64 bit.
I've designated the user as ABCD@XYZ@66.***.**.*** in the command line, it's the same user that connects when I use the Command Interface.

The Log has a couple of interesting notes that I don't quite understand:
1. It indicates the "Using username "user". I assume that indicates that its using the username I indicated in the command line... its not actually using "User" as the username. I'm I right on that?

Then Password authentication failed and Access is Denied.

The WinSCP.ini file is in the same directory as the WinSCP.exe and WinSCP.com applications. When WinSCP runs from the command line, does it get the password from WinSCP.ini by matching the username provided in the command line?


Thanks for your help.
These are the settings when I use the command line in Task Manager:

Actions Tab:
Program/Script: C:\Users\****\Downloads\FTP\winscp438\WinSCP.exe

Add Arguments: "C:\Users\****\Downloads\FTP\winscp438\WinSCP.exe" /command "option confirm off" "open user:ABCD_XYZ@66.***.**.***" "put C:\Users\****\Documents\Export.xml" /log=C:\Secure_FTP_Log.txt "exit"


The Secure_FTP_Log is attached:

Reply with quote

Advertisement

martin
Site Admin
martin avatar
Joined:
Posts:
41,442
Location:
Prague, Czechia

Re: SFTP works in Command interface, not automatic.

kmideas wrote:

The Log has a couple of interesting notes that I don't quite understand:
1. It indicates the "Using username "user". I assume that indicates that its using the username I indicated in the command line... its not actually using "User" as the username. I'm I right on that?
It's actually using "User" as the username.
Reason for that is, that WinSCP did not find a stored session called "user@66.***.**.***" in the C:\Users\****\Downloads\FTP\winscp438\WinSCP.ini, so it considered it a session URL and parsed into into username "user" and hostname "66.***.**.***". I just wonder where it did get the password from.

Make sure you use name of the stored session exactly.

Reply with quote

kmideas
Joined:
Posts:
4

Re: SFTP works in Command interface, not automatic.

I got the connection to work by updating the command string to:

"C:\Program Files (x86)\WinSCP\WinSCP.exe" /command "option confirm off" "open ABCD_XYZ@66.***.**.***" -cmd="put C:\Users\My Docs\Documents\Export Files\Data_Export\Export.xml" /log=C:\Secure_FTP_Log.txt "exit"

I'm using the -cmd to make the put command work because I wasn't able to get it to work using double quotes.

The error log indicates the path on the server isn't designated. However when I run session user in Command Interface, I log into the correct directory on the server.

. 2012-07-23 13:24:09.196 Using SFTP protocol.
. 2012-07-23 13:24:09.198 Doing startup conversation with host.
> 2012-07-23 13:24:09.198 Type: SSH_FXP_INIT, Size: 5, Number: -1
< 2012-07-23 13:24:09.423 Type: SSH_FXP_VERSION, Size: 5, Number: -1
. 2012-07-23 13:24:09.423 SFTP version 3 negotiated.
. 2012-07-23 13:24:09.423 We believe the server has signed timestamps bug
. 2012-07-23 13:24:09.423 We will use UTF-8 strings for status messages only
. 2012-07-23 13:24:09.424 Getting current directory name.
. 2012-07-23 13:24:09.424 Getting real path for '.'
> 2012-07-23 13:24:09.424 Type: SSH_FXP_REALPATH, Size: 10, Number: 16
< 2012-07-23 13:24:09.437 Type: SSH_FXP_NAME, Size: 23, Number: 16
. 2012-07-23 13:24:09.437 Real path is '/'
. 2012-07-23 13:24:09.437 Startup conversation with host finished.
< 2012-07-23 13:24:09.437 Script: Active session: [1] ABCD_XYZ@66.***.**.***
. 2012-07-23 13:24:09.437 Script: Exit code: 0
. 2012-07-23 13:24:09.437 Closing connection.
. 2012-07-23 13:24:09.437 Sending special code: 12
. 2012-07-23 13:24:09.438 Sent EOF message

Where do I designate the real path for '.'
and Real path is '/' ?

Thanks

Reply with quote

kmideas
Joined:
Posts:
4

Re: SFTP works in Command interface, not automatic.

kmideas wrote:

I got the connection to work by updating the command string to:

"C:\Program Files (x86)\WinSCP\WinSCP.exe" /command "option confirm off" "open ABCD_XYZ@66.***.**.***" -cmd="put C:\Users\My Docs\Documents\Export Files\Data_Export\Export.xml" /log=C:\Secure_FTP_Log.txt "exit"

I'm using the -cmd to make the put command work because I wasn't able to get it to work using double quotes.

The error log indicates the path on the server isn't designated. However when I run session user in Command Interface, I log into the correct directory on the server.

. 2012-07-23 13:24:09.196 Using SFTP protocol.
. 2012-07-23 13:24:09.198 Doing startup conversation with host.
> 2012-07-23 13:24:09.198 Type: SSH_FXP_INIT, Size: 5, Number: -1
< 2012-07-23 13:24:09.423 Type: SSH_FXP_VERSION, Size: 5, Number: -1
. 2012-07-23 13:24:09.423 SFTP version 3 negotiated.
. 2012-07-23 13:24:09.423 We believe the server has signed timestamps bug
. 2012-07-23 13:24:09.423 We will use UTF-8 strings for status messages only
. 2012-07-23 13:24:09.424 Getting current directory name.
. 2012-07-23 13:24:09.424 Getting real path for '.'
> 2012-07-23 13:24:09.424 Type: SSH_FXP_REALPATH, Size: 10, Number: 16
< 2012-07-23 13:24:09.437 Type: SSH_FXP_NAME, Size: 23, Number: 16
. 2012-07-23 13:24:09.437 Real path is '/'
. 2012-07-23 13:24:09.437 Startup conversation with host finished.
< 2012-07-23 13:24:09.437 Script: Active session: [1] ABCD_XYZ@66.***.**.***
. 2012-07-23 13:24:09.437 Script: Exit code: 0
. 2012-07-23 13:24:09.437 Closing connection.
. 2012-07-23 13:24:09.437 Sending special code: 12
. 2012-07-23 13:24:09.438 Sent EOF message

Where do I designate the real path for '.'
and Real path is '/' ?

Thanks

I got it to work by using the following:
"C:\Program Files (x86)\WinSCP\WinSCP.exe" /command "option confirm off" "open ABCD_XYZ@66.***.**.***" "put C:\Export.xml" /log=C:\Secure_FTP_Log.txt "exit"

I moved the file to be FTP'd to the root folder. The previous location had spaces in the folder names. I couldn't figure out how to use the double-quotes to handle them.

If the file is in C:\Users\My Docs\Documents\Export Files\Data_Export\Export.xml
I've tried: "put "C:\Users\My Docs\Documents\Export Files\Data_Export\Export.xml"",
"put C:\Users\"My Docs"\Documents\"Export Files"\Data_Export\Export.xml""

How do you do it?

Thanks

Reply with quote

Advertisement

martin
Site Admin
martin avatar
Joined:
Posts:
41,442
Location:
Prague, Czechia

Add Arguments: "C:\Users\****\Downloads\FTP\winscp438\WinSCP.exe" /command "option confirm off" "open user:ABCD_XYZ@66.***.**.***" "put C:\Users\****\Documents\Export.xml" /log=C:\Secure_FTP_Log.txt "exit"
I noticed this only now.
The "user:ABCD_XYZ@66.***.**.***" says, use username "user", password "ABCD_XYZ", hostname "66.***.**.***".
See https://winscp.net/eng/docs/session_url

I'm using the -cmd to make the put command work because I wasn't able to get it to work using double quotes.
There's nothing like -cmd.

If the file is in C:\Users\My Docs\Documents\Export Files\Data_Export\Export.xml
I've tried: "put "C:\Users\My Docs\Documents\Export Files\Data_Export\Export.xml"",
"put C:\Users\"My Docs"\Documents\"Export Files"\Data_Export\Export.xml""
"put ""C:\Users\My Docs\Documents\Export Files\Data_Export\Export.xml"""
See https://winscp.net/eng/docs/commandline#syntax

Reply with quote

Advertisement

You can post new topics in this forum