Differences

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

2006-09-26 2006-09-26
pipes can be used with console interface tool (martin) remade, link script_commands (martin)
Line 1: Line 1:
====== Scripting/Automation ====== ====== Scripting/Automation ======
 +In addition to [[interfaces|graphical interface]], WinSCP offers scripting/console interface with many [[script_commands|commands]]. The commands can be typed in interactively, or read from script file or another source.
 +
 +===== Using Scripting =====
See [[commandline|Command-line parameters]] to learn how to enter the console/scripting mode. See [[commandline|Command-line parameters]] to learn how to enter the console/scripting mode.
-===== Commands ===== +For automation, commands can be read from a script file specified by ''/script'' switch, from standard input or passed from the command-line using the ''/command'' switch.
-The following commands are implemented: ''call'', ''cd'', ''chmod'', ''close'', ''exit'', ''get'', ''help'', ''keepuptodate'', ''lcd'', ''lls'', ''ln'', ''lpwd'', ''ls'', ''mkdir'', ''mv'', ''open'', ''option'', ''put'', ''pwd'', ''rm'', ''rmdir'', ''session'', ''synchronize'' and several aliases.+
-The command ''help <command>'' shows a comprehensive description of the ''command'' including examples and aliases.+By default an interactive mode is used (the user is prompted in the same way as in GUI mode). To switch to a batch mode (all prompts are automatically answered negatively) use the command ''[[script_commands#option|option batch on]]''. For the batch mode it is recommended to turn off confirmations using ''[[script_commands#option|option confirm off]]'' to allow overwrites (otherwise the overwrite confirmation prompt would be answered negatively, making overwrites impossible).
-Multiple sessions can be opened simultaneously. Use the ''session'' command to switch between them. Commands can be read from a script file specified by ''/script'' switch, from standard input or passed from the command-line using the ''/command'' switch.+Multiple sessions can be opened simultaneously. Use the ''[[script_commands#session|session]]'' command to switch between them.
-By default interactive mode is used (the user is prompted in the same way as in GUI mode). To switch to batch mode (all prompts are automatically answered negatively) use the command ''option batch on''. For the batch mode it is recommended to turn off confirmations using ''option confirm off'' to allow overwrites (otherwise the overwrite confirmation prompt would be answered negatively, making overwrites impossible).  +Note that the first connection to an SSH server requires [[ssh#verifying_the_host_key|verification of the host key]], which cannot be automated by scripting. Therefore, some provision for accepting keys must be made prior to running the script to connect to a new host. Never attempt to make the script verify the host key automatically.
- +
-Note also that the first connection to an SSH server requires [[ssh#verifying_the_host_key|verification of the host key]], which cannot be automated by scripting. Therefore, some provision for accepting keys must be made prior to running the script to connect to a new host. Never attempt to make the script verify the host key automatically.+
WinSCP returns exit code 1, when any command is interrupted due to an error or any prompt is answered //Abort// (even automatically in batch mode). Otherwise it returns the exit code 0. WinSCP returns exit code 1, when any command is interrupted due to an error or any prompt is answered //Abort// (even automatically in batch mode). Otherwise it returns the exit code 0.
 +
 +===== Commands =====
 +The following commands are implemented:
 +
 +^ Command                          ^ Description ^
 +| [[script_commands#call|call]]    | Executes arbitrary remote shell command |
 +| [[script_commands#cd|cd]]        | Changes remote working directory |
 +| [[script_commands#chmod|chmod]]  | Changes permissions of remote file |
 +| [[script_commands#close|close]]  | Closes session |
 +| [[script_commands#exit|exit]]    | Closes all sessions and terminates the program |
 +| [[script_commands#get|get]]      | Downloads file from remote directory to local directory |
 +| [[script_commands#help|help]]    | Displays help |
 +| [[script_commands#keepuptodate|keepuptodate]] | Continuously reflects changes in local directory on remote one |
 +| [[script_commands#lcd|lcd]]      | Changes local working directory |
 +| [[script_commands#lls|lls]]      | Lists the contents of local directory |
 +| [[script_commands#ln|ln]]        | Creates remote symbolic link |
 +| [[script_commands#lpwd|lpwd]]    | Prints local working directory |
 +| [[script_commands#ls|ls]]        | Lists the contents of remote directory |
 +| [[script_commands#mkdir|mkdir]]  | Creates remote directory |
 +| [[script_commands#mv|mv]]        | Moves or renames remote file |
 +| [[script_commands#open|open]]    | Connects to server |
 +| [[script_commands#option|option]] | Sets or shows value of script options |
 +| [[script_commands#put|put]]      | Uploads file from local directory to remote directory |
 +| [[script_commands#pwd|pwd]]      | Prints remote working directory |
 +| [[script_commands#rm|rm]]        | Removes remote file |
 +| [[script_commands#rmdir|rmdir]]  | Removes remote directory |
 +| [[script_commands#session|session]] | Lists connected sessions or selects active session |
 +| [[script_commands#synchronize|synchronize]] | Synchronizes remote directory with local one |
===== [[console]] The Console Interface Tool ===== ===== [[console]] The Console Interface Tool =====

Last modified: by martin