Post a reply

Before posting, please read how to report bug or request support effectively.

Bug reports without an attached log file are usually useless.

Options
Add an Attachment

If you do not want to add an Attachment to your Post, please leave the Fields blank.

(maximum 10 MB; please compress large files; only common media, archive, text and programming file formats are allowed)

Options

Topic review

martin

Re: Using Winscp.com in a Batchfile with Escape characters

The ^ in Windows batch file delimiter (it has nothing to do with WinSCP).
Make sure it's the very last character on the line (there cannot be any space after it).
And you typically need a space at the front of the next line.

See https://winscp.net/eng/docs/faq_batch_file
Moriarty91

Using Winscp.com in a Batchfile with Escape characters

Hello!
I am writing a batchfile to automatically upload a file to an sftp-server.
Using the following code works fine:
 C:\patch\to\winscp.com /log="C:\path\winscp.log" /loglevel=1 /command ^

"open user@sftp.psubdomain.server.com -privatekey=C:\path\key.ppk -hostkey=XX:XX:XX:XX:XX:XX:XX:XX:XX:XX:XX:XX:XX:XX:XX:XX" "put -resume -resumesupport=on -transfer=binary -delete C:\path\%filename%.ext users/name/path/" "exit"


But using the following code which I have copied from the documentation produces errors:
C:\patch\to\winscp.com /log="C:\path\winscp.log" /loglevel=1 ^

     "open user@sftp.psubdomain.server.com -privatekey=C:\path\key.ppk -hostkey=XX:XX:XX:XX:XX:XX:XX:XX:XX:XX:XX:XX:XX:XX:XX:XX" ^
     "put -resume -resumesupport=on -transfer=binary -delete C:\path\%filename%.ext users/name/path/" ^
     "exit"

I have copied the codesample above from the documentation and WinSCP either says "Unknown command: ^" after executing the "open ..." line (so the second ^ is not recognized) and the following WinSCP-commands "put..." and "exit" are then interpreted by cmd in the batch file and not WinSCP as part of its commands.
The other error I get from WinSCP is "Unknown command: open user@sftp.psubdomain.server.com -privatekey=C".
I have not figured out, which error is triggered when and I don't know what is wrong as the logfile simply seems to repeat these errors.
Thanks for your help!
Moriarty91