Differences

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

scripting 2021-11-16 scripting 2024-02-29 (current)
Line 52: Line 52:
-==== [[variables]] Environment Variablesss ====+==== [[variables]] Environment Variables ====
You can use environment variables in the commands, with syntax ''%NAME%'':((Generally do surround reference by double-quotes to cope properly with spaces in its value.)) You can use environment variables in the commands, with syntax ''%NAME%'':((Generally do surround reference by double-quotes to cope properly with spaces in its value.))
Line 80: Line 80:
put "%1%" put "%1%"
</code> </code>
-chris stinkt 
==== Case Sensitivity of File Names ==== ==== Case Sensitivity of File Names ====
Line 86: Line 85:
Note that WinSCP treats filenames in case sensitive manner. So even if your server treats filenames in case insensitive manner, make sure you specify case properly.((This is important particularly for FTP sessions.)) Note that WinSCP treats filenames in case sensitive manner. So even if your server treats filenames in case insensitive manner, make sure you specify case properly.((This is important particularly for FTP sessions.))
-+==== [[comments]] Comments ==== 
 + 
 +To insert comments into the script file, start the line with ''#'' (hash): 
 +<code winscp> 
 +# Connect to the server 
 +open mysession 
 +</code>
===== [[commands]] Commands ===== ===== [[commands]] Commands =====
Line 135: Line 140:
===== [[different_account]] Running a Script under a Different Account (e.g., Using a Scheduler) ===== ===== [[different_account]] Running a Script under a Different Account (e.g., Using a Scheduler) =====
-If you are going to run the script under a different account (for example [[guide_schedule|using the Windows Task Scheduler]]), make sure the script does not rely on a configuration settings that might differ on the other account. When using registry as [[config|configuration storage]], the settings are accessible only for your Windows account. Ideally, make sure the script does not really on any external configuration, to make it completely portable. Note that the configuration also includes [[#hostkey|verified SSH host keys]] and FTPS/WebDAVS [[tls#certificate|TLS/SSL certificates]]. +If you are going to run the script under a different account (for example [[guide_schedule|using the Windows Task Scheduler]]), make sure the script does not rely on a configuration settings that might differ on the other account. When using registry as [[config|configuration storage]], the settings are accessible only for your Windows account. Ideally, make sure the script does not rely on any external configuration, to make it completely portable. Note that the configuration also includes [[#hostkey|verified SSH host keys]] and FTPS/WebDAVS [[tls#certificate|TLS/SSL certificates]].
//For details, see the [[#configuration|next section]] and [[faq_environment|*]]// //For details, see the [[#configuration|next section]] and [[faq_environment|*]]//
Line 158: Line 163:
<code winscp> <code winscp>
# Connect # Connect
-open sftp://user:password@example.com/ -hostkey="ssh-rsa 2048 xxxxxxxxxxx...="+open sftp://user:password@example.com/ -hostkey="ssh-rsa 2048 xxxxxxxxxxx..."
# Change remote directory # Change remote directory
cd /home/user cd /home/user
Line 183: Line 188:
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 batch> <code batch>
-winscp.com /ini=nul /command "open sftp://user:password@example.com/ -hostkey=""ssh-rsa 2048 xxxxxxxxxxx...=""" "get examplefile.txt d:\" "exit"+winscp.com /ini=nul /command "open sftp://user:password@example.com/ -hostkey=""ssh-rsa 2048 xxxxxxxxxxx...""" "get examplefile.txt d:\" "exit"
</code> </code>
Line 190: Line 195:
<code batch> <code batch>
winscp.com /ini=nul /command ^ winscp.com /ini=nul /command ^
-    "open sftp://user:password@example.com/ -hostkey=""ssh-rsa 2048 xxxxxxxxxxx...=""" ^+    "open sftp://user:password@example.com/ -hostkey=""ssh-rsa 2048 xxxxxxxxxxx...""" ^
    "get examplefile.txt d:\" ^     "get examplefile.txt d:\" ^
    "exit"     "exit"

Last modified: by 85.16.131.117