Here is the sample script I use to copy from Unix Host to Windows Host by DOS Batch will using WinSCP.
Main Script
@echo off del .\WinSCP_Copy.log /Q cd "D:\Documents and Settings\Siva\My Documents\SQL_Pack\WinSCP\D1_Copy.txt" /log="D:\Documents and Settings\Siva\My Documents\SQL_Pack\WinSCP\" call UnixBox_Copy.bat "C:\Program Files\WinSCP\WinSCP.exe" /console /script="D:\Documents and Settings\Siva\My Documents\SQL_Pack\WinSCP\UnixBox1_Copy_Script.txt" /log="D:\Documents and Settings\Siva\My Documents\SQL_Pack\WinSCP\WinSCP_Copy.log" @echo on |
UnixBox_Copy.bat
set lan_dir=D:\Documents and Settings\Siva\My Documents\SQL_Pack\WinSCP :: To execute the script "C:\Program Files\WinSCP\WinSCP.exe" /console /script="D:\Documents and Settings\Siva\My Documents\SQL_Pack\WinSCP\D1_Copy.txt" :: To switch to batch mode & Automatically abort script on errors echo option batch abort > .\UnixBox1_Copy_Script.txt :: Disable overwrite confirmations that conflict with the previous echo option confirm off >> .\UnixBox1_Copy_Script.txt :: connect using a password echo open sftp://%uname%:%pwd%@unixDBsrvr1.production.siva.com >> .\UnixBox1_Copy_Script.txt cd "%lan_dir%" IF NOT EXIST "%unix_dir2%" (mkdir "%lan_dir%\"%unix_dir2% ) ELSE ( GOTO _END ) echo lcd "%lan_dir%\%unix_dir2%" >> .\UnixBox1_Copy_Script.txt :: Force binary mode transfer :: Download the file to local directory Y:\ :: Disconnect :: Exit WinSCP :_END |
Sample UnixBox1_Copy_Script.txt, generated by UnixBox_Copy.bat. The following Script is called on WinSCP as set of command to execute on WinSCP console.
option batch abort |
No comments:
Post a Comment