Topic "SFTP works in Command interface, not automatic."

Author Message
kmideas
[View user's profile]

Joined: 2012-07-20
Posts: 4
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:
Advertisements
kmideas
[View user's profile]

Joined: 2012-07-20
Posts: 4
Here's the log file
Secure_FTP_Log.txt (5.31 KB) [Download]

Description: Log created from command line run in MS Scheduled Tasks

martin
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 25034
Location: Prague, Czechia
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.
_________________
Martin Prikryl
kmideas
[View user's profile]

Joined: 2012-07-20
Posts: 4
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
kmideas
[View user's profile]

Joined: 2012-07-20
Posts: 4
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
martin
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 25034
Location: Prague, Czechia
Quote:
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

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

Quote:
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
_________________
Martin Prikryl
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