Differences
This shows you the differences between the selected revisions of the page.
2014-03-24 | 2014-03-25 | ||
reverting alternative VB.net code as I got no explanation in topics 13603 and 13598 what does it show (martin) | upload_multiple_servers (martin) | ||
Line 24: | Line 24: | ||
winscp.com /script=example.txt | winscp.com /script=example.txt | ||
</code> | </code> | ||
+ | |||
+ | ===== [[upload_multiple_servers]] Upload to Multiple Servers/Parametrized Script ===== | ||
+ | If you need to repeat the same task against multiple servers, instead of writing separate and almost identical [[scripting|scripts]] for each server, you can write one parametrized script. | ||
+ | |||
+ | Following example is parametrized script that accepts one [[scripting#syntax|parameter]] with [[session_url|session URL]] and uploads a fixed local file to a fixed remote directory: | ||
+ | |||
+ | <code winscp> | ||
+ | option batch abort | ||
+ | option confirm off | ||
+ | open %1% | ||
+ | put examplefile.txt /home/user/ | ||
+ | exit | ||
+ | </code> | ||
+ | |||
+ | To use the script against multiple servers, just execute the script (saved to file ''script.txt'') repeatedly, using different [[session_url|session URL]] as parameter: | ||
+ | |||
+ | <code> | ||
+ | winscp.com /script=script.txt /parameter sftp://martin@server1.example.com/ | ||
+ | winscp.com /script=script.txt /parameter sftp://test@server2.example.com/ | ||
+ | </code> | ||
+ | |||
+ | If the script has also other variable parts, like file to upload or remote directory, just replace those parts with additional parameters (''%2%'', ''%3%'', etc). | ||