Differences
This shows you the differences between the selected revisions of the page.
2011-02-14 | 2011-03-18 | ||
scripts (martin) | no summary (92.86.154.166) (hidden) | ||
Line 1: | Line 1: | ||
+ | 317 | ||
+ | |||
====== Scripting/Automation ====== | ====== Scripting/Automation ====== | ||
//This article contains detailed description of scripting/automation functionality. You may want to see [[guide_automation|simplified guide]] to the functionality instead.// | //This article contains detailed description of scripting/automation functionality. You may want to see [[guide_automation|simplified guide]] to the functionality instead.// | ||
Line 4: | Line 6: | ||
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. | 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. | ||
- | &screenshotpict(scripting) | + | &screenshotpict(scripting) |
===== Using Scripting ===== | ===== Using Scripting ===== | ||
Line 68: | Line 70: | ||
===== Example ===== | ===== Example ===== | ||
The example below connects to ''example.com'' server with account ''user'', downloads file and closes the session. Then it connects to the same server with the account ''user2'' and uploads the file back. | The example below connects to ''example.com'' server with account ''user'', downloads file and closes the session. Then it connects to the same server with the account ''user2'' and uploads the file back. | ||
- | <code winscp> | + | &lt;code winscp&gt; |
# Automatically answer all prompts negatively not to stall | # Automatically answer all prompts negatively not to stall | ||
# the script on errors | # the script on errors | ||
Line 96: | Line 98: | ||
# Exit WinSCP | # Exit WinSCP | ||
exit | exit | ||
- | </code> | + | &lt;/code&gt; |
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. | 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> | + | &lt;code&gt; |
winscp.exe /console /script=example.txt | winscp.exe /console /script=example.txt | ||
- | </code> | + | &lt;/code&gt; |
For simple scripts you can specify all the commands on [[commandline|command-line]] using ''/command'' switch: | For simple scripts you can specify all the commands on [[commandline|command-line]] using ''/command'' switch: | ||
- | <code> | + | &lt;code&gt; |
- | winscp.exe /console /command "option batch on" "open user@example.com" "get examplefile.txt d:\" "exit" | + | winscp.exe /console /command &quot;option batch on&quot; &quot;open user@example.com&quot; &quot;get examplefile.txt d:\&quot; &quot;exit&quot; |
- | </code> | + | &lt;/code&gt; |
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. | 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> | + | &lt;code&gt; |
winscp.exe /console /script=example.txt user@example.com | winscp.exe /console /script=example.txt user@example.com | ||
- | </code> | + | &lt;/code&gt; |
===== Further Reading ===== | ===== Further Reading ===== | ||
Line 116: | Line 118: | ||
* [[faq#scripting_automation|FAQs about scripting]]; | * [[faq#scripting_automation|FAQs about scripting]]; | ||
* [[scripts|Useful example scripts]]. | * [[scripts|Useful example scripts]]. | ||
- |