Differences
This shows you the differences between the selected revisions of the page.
2005-09-08 | 2005-11-20 | ||
no summary (62.134.176.182) | english more idiomatic (mjb) | ||
Line 3: | Line 3: | ||
===== Commands ===== | ===== Commands ===== | ||
- | 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 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. |
- | Command ''help <command>'' shows comprehensive description of the ''command'' including examples and aliases. | + | The command ''help <command>'' shows a comprehensive description of the ''command'' including examples and aliases. |
- | Multiple sessions can be opened simultaneously. Use ''session'' command to switch among them. Commands can be read from script file or passed from command-line using ''/command'' switch. | + | Multiple sessions can be opened simultaneously. Use the ''session'' command to switch between them. Commands can be read from a script file or passed from the command-line using the ''/command'' switch. |
- | By default interactive mode is used (user is prompted in the same way as in GUI mode). To switch to batch mode (all prompts are automatically answered negatively) use 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). | + | 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). |
- | 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 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. |
- | ===== Console Interface Tool ===== | + | ===== The Console Interface Tool ===== |
- | As ''WinSCP3.exe'' is a GUI application, it cannot inherit console window when run from another console application (like Windows command-prompt). To allow this, run WinSCP using the console interface tool ''WinSCP3.com'' (you can find ''WinSCP3.com'' in the main [[installation|installation package]]). | + | As ''WinSCP3.exe'' is a GUI application, it cannot inherit the console window when run from another console application (such as the Windows command-prompt). To allow this, run WinSCP using the console interface tool ''WinSCP3.com'' (you can find ''WinSCP3.com'' in the main [[installation|installation package]]). |
- | ===== Running Script under Different Account ===== | + | ===== Running a Script under a Different Account ===== |
- | If you are going to run the script under different account (for example using Windows scheduler), note that WinSCP [[config|stores configuration]] to user part of Windows Registry by default. So you may need either to transfer the configuration from your account registry to the other account registry or use [[config|INI file]] instead. | + | If you are going to run the script under a different account (for example using the Windows scheduler), note that WinSCP [[config|stores its configuration]] to the user part of Windows Registry by default. So you may need to either transfer the configuration from your account registry to the other account registry or use the [[config|INI file]] instead. |
- | Note that the configuration also includes [[ssh#verifying_the_host_key|verified host keys]], which you may need to transfer too (or confirm manually under the account) to allow automatic execution of the script. Never attempt to make the script [[ssh#verifying_the_host_key|verify the host key]] automatically. | + | Note that the configuration also includes [[ssh#verifying_the_host_key|verified host keys]], which you may need to transfer as well (or confirm manually under the account) to allow automatic execution of the script. Never attempt to make the script [[ssh#verifying_the_host_key|verify the host key]] automatically. |
===== 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 account ''user2'' and upload 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> | <code winscp> | ||
- | # Automatically answer all prompts negativelly not to stall | + | # Automatically answer all prompts negatively not to stall |
# the script on errors | # the script on errors | ||
option batch on | option batch on | ||
- | # Disable overwrite confirmations that conflict with previous | + | # Disable overwrite confirmations that conflict with the previous |
option confirm off | option confirm off | ||
# Connect using a password | # Connect using a password | ||
Line 37: | Line 37: | ||
# Force binary mode transfer | # Force binary mode transfer | ||
option transfer binary | option transfer binary | ||
- | # Download file to local directory d:\ | + | # Download file to the local directory d:\ |
get examplefile.txt d:\ | get examplefile.txt d:\ | ||
# Disconnect | # Disconnect | ||
close | close | ||
- | # Connect as different user | + | # Connect as a different user |
open user2@example.com | open user2@example.com | ||
- | # Change remote directory | + | # Change the remote directory |
cd /home/user2 | cd /home/user2 | ||
- | # Upload file to current working directory | + | # Upload the file to current working directory |
put d:\examplefile.txt | put d:\examplefile.txt | ||
# Disconnect | # Disconnect | ||
Line 52: | Line 52: | ||
exit | exit | ||
</code> | </code> | ||
- | Save the script to file ''example.txt''. To execute the script file use following command. As the script connects the session itself, using command ''open'', omit the ''session'' command-line parameter. | + | Save the script to the file ''example.txt''. To execute the script file use following command. As the script connects the session itself, using the command ''open'', omit the ''session'' command-line parameter. |
<code> | <code> | ||
winscp3 /console /script=example.txt | winscp3 /console /script=example.txt | ||
</code> | </code> | ||
- | Instead of using ''open'' command you can also open session using [[commandline|command-line parameter]]. | + | Instead of using ''open'' command you can also open a session using a [[commandline|command-line parameter]]. |
<code> | <code> | ||
winscp3 /console /script=example.txt user@example.com | winscp3 /console /script=example.txt user@example.com | ||
</code> | </code> |