Differences

This shows you the differences between the selected revisions of the page.

2012-09-15 2012-09-15
no summary (84.245.14.29) (hidden) Restored revision 1339059073. Undoing revisions 1347703035, 1347703079. (Petr) (hidden)
Line 114: Line 114:
option confirm off option confirm off
# Connect using a password # Connect using a password
-# open sftp://*********+# open sftp://user:password@example.com -hostkey="ssh-rsa 1024 xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx"
# Connect # Connect
-# open sftp://user@example.com -hostkey="ssh-rsa 1024 xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx"+open sftp://user@example.com -hostkey="ssh-rsa 1024 xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx"
# Change remote directory # Change remote directory
-cd //private/var/mobile/Documents/Installous/Downloads/+cd /home/user
# Force binary mode transfer # Force binary mode transfer
option transfer binary option transfer binary
# Download file to the local directory d:\ # Download file to the local directory d:\
-get *.png d:\+get examplefile.txt d:\
# Disconnect # Disconnect
close close
 +# Connect as a different user
 +open user2@example.com
 +# Change the remote directory
 +cd /home/user2
 +# Upload the file to current working directory
 +put d:\examplefile.txt
 +# Disconnect
 +close
 +# Exit WinSCP
 +exit
 +</code>
 +Save the script to the file ''example.txt''. To execute the script file use the following command. As the script connects the session itself, using the command ''open'', omit the ''session'' command-line parameter.
 +<code>
 +winscp.exe /console /script=example.txt
 +</code>
 +
 +For simple scripts you can specify all the commands on [[commandline|command-line]] using ''/command'' switch:
 +<code>
 +winscp.exe /console /command "option batch abort" "open user@example.com" "get examplefile.txt d:\" "exit"
 +</code>
 +
 +Instead of using ''open'' command you can also open a session using a [[commandline|command-line parameter]]. Note that in that case session is opened yet before script starts. Particularly ''option'' commands do not apply yet. Generally you should avoid using this method.
 +<code>
 +winscp.exe /console /script=example.txt user@example.com
</code> </code>

Last modified: by Petr