Unable to get 'put' script to work

Advertisement

dubscat01
Joined:
Posts:
1

Unable to get 'put' script to work

hello, and thanks in advance -

winscp version: 5.5.2 (build 4130)
windows 2010
protocal: FTP

i am trying to upload a .txt file, and i've templated a script off the example posted here:
https://winscp.net/forum/viewtopic.php?t=6767

the script generates the following strShell string:

"C:\Program Files (x86)\WinSCP\WinSCP.exe" userID:password@host.url "put \\local drive\local folder\FTP_Upload_Test.txt /ftp path folder/sub-folder/" "close"

which i execute with: Shell strShell

problems:
1. i've set up the host login with the userID and password that i'm assigning in the strShell string, and can login manually with no problem; however when i execute the shell command, it initially follows the same login sequence, but then says "access denied" and then asks for the pw to be entered again.

2. re-entereing the pw does allow the login to proceed successfully, but the file transfer does not occur

Reply with quote

Advertisement

Guest

Re: Unable to get 'put' script to work

martin wrote:

Your syntax is completely wrong. Please start here:
https://winscp.net/eng/docs/guide_automation

thank you for your response, martin -

ok, i've tried using both a .txt file ("example.txt") and invoking 'winscp.exe /console /script=example.txt', and, as above, using 'shell strShell'. i've reviewed the documentation as you mention, as well as the related examples, but still am simply unable to get it figured out. what/where, specifically, is my syntax wrong?

thanks again,

Reply with quote

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

Re: Unable to get 'put' script to work

- You are missing /command parameter before the commands.
- You are missing open command.
- Your paths with spaces are not enclosed in double-quotes.
- You are missing (almost mandatory) option batch abort and option confirm off commands.

Using /script= is definitely better for you as the syntax in script file is simpler than on command line.
You probably want to avoid /console (after you finish debugging this) to avoid console window poping up.
_________________
Martin Prikryl

Reply with quote

Guest

Re: Unable to get 'put' script to work

martin wrote:

- You are missing /command parameter before the commands.
- You are missing open command.
- Your paths with spaces are not enclosed in double-quotes.
- You are missing (almost mandatory) option batch abort and option confirm off commands.

Using /script= is definitely better for you as the syntax in script file is simpler than on command line.
You probably want to avoid /console (after you finish debugging this) to avoid console window poping up.


thanks again, martin -

ok, have reviewed again the documentation and tried to implement your suggestions (which i did see in the doc'n/examples). My strShell now is:

C:\Program Files (x86)\WinSCP\WinSCP.exe /command "option batch abort" "option confirm off" "open userID:password@xx.xx.xxxx" "put \\localDrive\localFolder\FTP_Upload_Test.txt /Monthly Reporting/2014/3-2014/" "exit"

as suggested, but this does not connect at all, now. i've also tried inserting '/console', and all possible iterations using c:\...\WinSCP.com without success.... May i ask, what should the exact string be? also, i'm not sure i understand the "paths with spaces" comment; have not seen double quotes around the files paths in any of the examples, else i'm misunderstanding(likely!).

Reply with quote

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

Re: Unable to get 'put' script to work

as suggested, but this does not connect at all, now. i've also tried inserting '/console', and all possible iterations using c:\...\WinSCP.com without success.... May i ask, what should the exact string be? also, i'm not sure i understand the "paths with spaces" comment; have not seen double quotes around the files paths in any of the examples, else i'm misunderstanding(likely!).

Should be:
... "put \\localDrive\localFolder\FTP_Upload_Test.txt ""/Monthly Reporting/2014/3-2014/""" ...

See https://winscp.net/eng/docs/commandline#syntax
_________________
Martin Prikryl

Reply with quote

Guest

Re: Unable to get 'put' script to work

martin wrote:

as suggested, but this does not connect at all, now. i've also tried inserting '/console', and all possible iterations using c:\...\WinSCP.com without success.... May i ask, what should the exact string be? also, i'm not sure i understand the "paths with spaces" comment; have not seen double quotes around the files paths in any of the examples, else i'm misunderstanding(likely!).

Should be:
... "put \\localDrive\localFolder\FTP_Upload_Test.txt ""/Monthly Reporting/2014/3-2014/""" ...

See https://winscp.net/eng/docs/commandline#syntax


appreciate your help, martin, but simply unable to get this! :oops: we'll just manually transfer the files for now - thanks again!

Reply with quote

Advertisement

You can post new topics in this forum