Topic "Using Winscp.com in a Batchfile with Escape characters"

Author Message
Moriarty91
[View user's profile]

Joined: 2016-08-05
Posts: 1
Hello!
I am writing a batchfile to automatically upload a file to an sftp-server.
Using the following code works fine:
Code:
 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:
Code:
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
martin
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 24512
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.
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