Using COMMAND and SCRIPT in Batch

Advertisement

ThomasM
Guest

Using COMMAND and SCRIPT in Batch

Hello!

I want use the /command AND the /script-option like this in a Batchfile:

winscp.exe /console /script=_Download.ftp /log=Winscp_LOG.txt /command "open sftp://xxx:yyy@server"

with _Download.ftp:
ls
ls /OUT
mget OUT/xxx_*.zip
ls /OUT

Reason: I want the Login-Name/Password in the Batchfile, and the "FTP-Commands" like put/get in an extra Scriptfile.

But it looks like, the script-file was not "called" (WinSCP/DOS-Window-Output):

D:\SFTP_Test\Download
Keine Sitzung
Keine Sitzung
Keine Sitzung
Keine Sitzung
Suche nach entferntem Rechner...
Verbinde mit entferntem Rechner...
Authentifiziere...
Verwende Benutzername "xxxxxxx".
Authentifikation mit zuvor eingegebenem Passwort.
Authentifiziert.
Starte die Sitzung...
Lese entferntes Verzeichnis...
Sitzung gestartet.
Aktive Sitzung: [1] xxxxxxxxxxxxx
winscp>

Reply with quote

Advertisement

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

Re: Using COMMAND and SCRIPT in Batch

/script happens before /command. So this won't work.

But you can use a parameterized script.

open %1%
ls 
ls /OUT 
mget OUT/xxx_*.zip 
ls /OUT

And call it like:
winscp.com /script=_Download.ftp /log=Winscp_LOG.txt /parameter sftp://xxx:yyy@server

See
https://winscp.net/eng/docs/scripting#arguments
https://winscp.net/eng/docs/script_upload_multiple_servers

Reply with quote

Advertisement

You can post new topics in this forum