Differences

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

scripts 2006-06-05 scripts 2021-03-31 (current)
Line 1: Line 1:
====== Useful Scripts ====== ====== Useful Scripts ======
-===== Downloading file to timestamped-filename =====+··* [[script_upload_single_file|*]] 
 +  * [[script_upload_multiple_servers|*]] 
 +  * [[script_download_timestamped_filename|*]] 
 + * [[script_download_most_recent_file|*]] 
 +  * [[script_upload_most_recent_file|*]] 
 +  * [[script_checking_file_existence|*]] 
 +  * [[script_local_move_after_successful_upload|*]] 
 +  * [[script_locking_files_while_uploading|*]] 
 +  * [[script_downloading_when_done_file_exists|*]] 
 +  * [[script_download_files_to_same_folder|*]] 
 +  * [[script_upload_file_list|*]] 
 +  * [[script_synchronize_any_local_file|*]] 
 +  * [[script_auto_compress_download|*]] 
 +  * [[script_custom_listing_format_csv|*]] 
 +  * [[script_retry|*]] 
 +  * [[script_formatting_timestamp_batch_file|*]] 
 +  * [[script_email|*]] 
 +  * [[script_vbnet_robust_example|*]]
-==== Using local-side scripting ==== +===== Other Examples ===== 
- +  * Guide to [[guide_automation|scripting/automation]]
-You can use any available scripting language you have on the local host to generate appropriate WinSCP script. Following example uses PHP language: +  * Guide to [[guide_automation_advanced|advanced scripting]]
- +  * See [[library_examples|*]] for advanced tasks.
-<code winscp> +
-get /home/user/examplefile.txt *.<?=date("YmdHis")?>.txt +
-exit +
-</code> +
- +
-Execute the script and store the results into temporary script file. The generated script file will look like: +
- +
-<code winscp> +
-get /home/user/examplefile.txt *.20060605090825.txt +
-exit +
-</code> +
- +
-Now pass the generated script file to WinSCP. You can automate all these steps using simple batch file: +
- +
-<code> +
-php -q download.php > "%temp%\download.tmp" +
-winscp3 user@example.com /console /script="%temp%\download.tmp"+
-del "%temp%\download.tmp" +
-</code> +
- +
-==== Using remote-side scripting ==== +
-If you do not have a scripting language on the local host, you can use remote-side script (like shell script). This approach requires opening separate [[shell session]] to invoke remote-side scripting: +
- +
-<code winscp>+
-# Make copy of the remote file to temporary timestamped file +
-# Also add unique extension to easily find the file in the temporary directory. +
-call cp /home/user/examplefile.txt /tmp/examplefile.`date +%Y%m%d%H%M%S`.unique +
-# Download all the files with the unique extension. There should be only one, the one just created. +
-# While downloading, remove the unique extension. +
-get /tmp/*.unique *. +
-# Remove the temporary file. +
-rm /tmp/*.unique +
-exit +
-</code>+

Last modified: by martin