Topic "Using in a Batchfile with Escape characters"

Author Message
[View user's profile]

Joined: 2016-08-05
Posts: 1
I am writing a batchfile to automatically upload a file to an sftp-server.
Using the following code works fine:
 C:\patch\to\ /log="C:\path\winscp.log" /loglevel=1 /command ^
"open -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\ /log="C:\path\winscp.log" /loglevel=1 ^
     "open -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/" ^

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 -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!
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 24736
Location: Prague, Czechia
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.

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!


About donations

$9   $19   $49   $99

About donations


WinSCP Privacy Policy

WinSCP License