Automating File Transfers using script.txt doesn't work

Advertisement

handelsmann
Guest

Automating File Transfers using script.txt doesn't work

Hi Martin
I'm trying to automate file transfers using a batch file and a script file as per your instructions in "Automate file transfers (or synchronization) to FTP server or SFTP server".
This is my batch file (TESTscript.bat):
winscp.com /script=TESTscript.txt /ini=nul /log=TESTscript.log
My script file (TESTscript.txt) looks like this (my original file has of course proper credentials etc.):
# Connect to SFTP server using a password
open sftp://user:password@example.com/ -hostkey="ssh-ed25519 xxxxx..."
# Synchronize files
put D:\000-Download-Auf-D\7-ZipPortable\--TestFTP.txt /xxxxx/xx/xx/xxxxxxxx/home/ftp/Test
# Exit WinSCP
exit
With the right credentials and ssh-key WinSCP connects to the SFTP server like a charm. No problems there.
But then the script just exits. It doesn't seem to find the put-command (nor synchronize remote-command which I tried as well) .
TESTscript.log after logging successful connection shows the following:
. 2024-10-25 10:29:22.475 Startup conversation with host finished.
< 2024-10-25 10:29:22.475 Script: Session started.
< 2024-10-25 10:29:22.476 Script: Active session: [1] user.example.com
> 2024-10-25 10:29:22.477 Script: ssh-ed25519 255 xxxxx..."
< 2024-10-25 10:29:22.477 Script: Unknown command 'ssh-ed25519'.
. 2024-10-25 10:29:22.477 Script: Failed
. 2024-10-25 10:29:22.477 Script: Exit code: 1
. 2024-10-25 10:29:22.477 Closing connection.
. 2024-10-25 10:29:22.477 Sending special code: 1
. 2024-10-25 10:29:22.480 Session sent command exit status 0
. 2024-10-25 10:29:22.480 Main session channel closed
. 2024-10-25 10:29:22.480 All channels closed
I am particularily confused by
> 2024-10-25 10:29:22.477 Script: ssh-ed25519 255 xxxxx..."
< 2024-10-25 10:29:22.477 Script: Unknown command 'ssh-ed25519'. 
I vaguely suspect that I'm doing something wrong with the double-quotes but I tried every possible variation of double-quoting to no avail. There are no blank spaces in my paths anyways.
I'd appreciate your help very much.
(I'm on Windows Server 2016 using WinSCP 6.3.5 Portable)

Reply with quote

Advertisement

martin
Site Admin
martin avatar
Joined:
Posts:
41,442
Location:
Prague, Czechia

Re: Automating File Transfers using script.txt doesn't work

Your script file is correct, and if the open command is provided with credentials and fingerprint is correct format, it cannot produce the error you are getting. So it's hard to help without seeing a less sanitized script.
At the very least, the fingerprint of server's public key is not secret, you can share that part.

Reply with quote

Guest

Re: Automating File Transfers using script.txt doesn't work

Hi
Thanks so much for your reply. You put me on the right track. I was being stupid with copy-pasting the server's fingerprint. I inadvertently added the MD5 of the public key. My bad. After deleting the MD5 from the script everything worked fine. Thanks again and sorry for trespassing on your time.

Bjoern

Reply with quote

Advertisement

You can post new topics in this forum