commandline » Revisions »
Differences
This shows you the differences between the selected revisions of the page.
2010-01-29 | 2010-01-29 | ||
winscp.com for scripts (martin) | examples (martin) | ||
Line 45: | Line 45: | ||
With ''/log'' parameter you may turn on [[logging|session logging]] to file specified by [[local_path|local path]]. If the log file name has ''.xml'' extension, [[logging_xml|XML logging]] is used. | With ''/log'' parameter you may turn on [[logging|session logging]] to file specified by [[local_path|local path]]. If the log file name has ''.xml'' extension, [[logging_xml|XML logging]] is used. | ||
+ | |||
+ | <code> | ||
+ | winscp.exe "My session" | ||
+ | winscp.exe sftp://martin@example.com /hostkey="ssh-rsa 1024 xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx" | ||
+ | winscp.exe scp://test@example.com:2222 /privatekey=mykey.ppk | ||
+ | winscp.exe ftps://martin@example.com /implicit /certificate="xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx" | ||
+ | winscp.exe martin@example.com /log="C:\winscp.log" | ||
+ | </code> | ||
==== [[scripting]] Console/scripting mode ==== | ==== [[scripting]] Console/scripting mode ==== | ||
Parameter ''/console'' executes WinSCP in [[scripting|console (scripting) mode]]. Note that when using ''[[executables|winscp.com]]'', the console mode is implicit, so using ''/console'' parameter is redundant. | Parameter ''/console'' executes WinSCP in [[scripting|console (scripting) mode]]. Note that when using ''[[executables|winscp.com]]'', the console mode is implicit, so using ''/console'' parameter is redundant. | ||
- | To run batch script either pass script file using ''/script'' parameter or specify the commands directly on command line using ''/command''. In the latter case each following parameter is treated as single command. If the command includes spaces (most does), enclose it in double-quotes. If the command itself includes double-quotes (e.g. to enclose filename with spaces), double them. ((''%%winscp.exe /console /command "option batch on" "open ""session with space"""%%'')) | + | To run batch script either pass script file using ''/script'' parameter or specify the commands directly on command line using ''/command''. In the latter case each following parameter is treated as single command. See [[commandline#syntax|syntax section]] and examples below for details how to deal with spaces and double-quotes. |
If both ''/script'' and ''/command'' parameters are used, commands from script file are executed first. When the last command is not ''[[script_commands#exit|exit]]'', regular non-batch mode follows. | If both ''/script'' and ''/command'' parameters are used, commands from script file are executed first. When the last command is not ''[[script_commands#exit|exit]]'', regular non-batch mode follows. | ||
Line 56: | Line 64: | ||
With ''[[executables|winscp.exe]]'', if ''/console'' parameter is not used along with ''/script'' or ''/command'', the script/command is executed without visual feedback (window). | With ''[[executables|winscp.exe]]'', if ''/console'' parameter is not used along with ''/script'' or ''/command'', the script/command is executed without visual feedback (window). | ||
+ | |||
+ | <code> | ||
+ | winscp.com /script="C:\Documents and Settings\martin\Documents\myscript.txt" | ||
+ | winscp.com /command "open ""My session"" -hostkey=""ssh-rsa 1024 xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx""" | ||
+ | winscp.com /command "open ""My session"" "put ""C:\Documents and Settings\martin\Documents\myfile.dat""" | ||
+ | winscp.exe /console /script="myscript.txt" | ||
+ | </code> | ||
==== Operations ==== | ==== Operations ==== | ||
Line 65: | Line 80: | ||
Use ''/defaults'' parameter along with ''/upload'', ''/synchronize'' or ''/keepuptodate'' to skip the settings dialog and start the operation straight away with default settings. | Use ''/defaults'' parameter along with ''/upload'', ''/synchronize'' or ''/keepuptodate'' to skip the settings dialog and start the operation straight away with default settings. | ||
+ | |||
+ | <code> | ||
+ | winscp.com /defaults /synchronize "C:\Documents and Settings\martin\Documents\MySite" /home/martin/public_html | ||
+ | </code> | ||
==== Configuration ==== | ==== Configuration ==== | ||
With ''/ini'' parameter you may specify [[local_path|local path]] to [[config|configuration INI file]]. It effectively disables using [[config|registry as configuration storage]]. If the file does not exist, default configuration will be used and the file will be created. | With ''/ini'' parameter you may specify [[local_path|local path]] to [[config|configuration INI file]]. It effectively disables using [[config|registry as configuration storage]]. If the file does not exist, default configuration will be used and the file will be created. | ||
+ | |||
+ | <code> | ||
+ | winscp.exe /ini="C:\Documents and Settings\martin\Documents\myconfig.ini" | ||
+ | </code> | ||
==== Auxiliary ==== | ==== Auxiliary ==== | ||
Line 74: | Line 97: | ||
Parameter ''/help'' shows usage (overview similar to this). | Parameter ''/help'' shows usage (overview similar to this). | ||
- | ===== Syntax ===== | + | ===== [[syntax]] Syntax ===== |
Command-line parameters that include space(s) have to be enclosed in double-quotes: | Command-line parameters that include space(s) have to be enclosed in double-quotes: | ||
<code> | <code> | ||
- | winscp.exe /ini="C:\Documents and Settings\user\Documents\myconfig.ini" | + | winscp.exe /ini="C:\Documents and Settings\martin\Documents\myconfig.ini" |
</code> | </code> | ||
To use double-quote literally, double it. You will need this particularly with ''/command'' parameter to execute script command that includes script parameter with spaces((Note that [[script_commands#syntax|doubling double-quotes]] applies to script command as well.)): | To use double-quote literally, double it. You will need this particularly with ''/command'' parameter to execute script command that includes script parameter with spaces((Note that [[script_commands#syntax|doubling double-quotes]] applies to script command as well.)): | ||
<code> | <code> | ||
- | winscp.com /command "open ""My session""" "put ""C:\Documents and Settings\user\Documents\myfile.dat""" | + | winscp.com /command "open ""My session""" "put ""C:\Documents and Settings\martin\Documents\myfile.dat""" |
</code> | </code> | ||