Hi Script junkies,
I am trying to get some help with a script to zip and upload a bunch of documents to a SFTP server. Here is the scenario:
1. An automatic SQL job would dump a large no of files into a folder location.
2. My script needs to go to this folder location and zip the files using any standard zipping tool.
3. The zipped file would be transferred to FTP source folder
4. SFTP client call to communicate with SFTP server and and upload the file. Close connections
5. Move zip file to archive location post upload
It would be great if these steps could be logged in a file as an audit trail for the process. I have the individual components but need some help in integrating the steps into one working script.
Step 1 Zip file: "C:\Program Files\7-Zip\7z" a name_%date:~4,2%-%date:~7,2%-%date:~10%.zip *.* >name_%date:~4,2%-%date:~7,2%-%date:~10%.txt
Step 2 Zipping log : move zipLog*.txt D:\LogLocation\Logs
Step 3 Move zip files to source folder: move fileName*.zip D:\SourceLoc\Staging
Step 4 SFTP Client connect: "C:\Program Files (x86)\\Bitvise SSH Client" sftpc -profile=Test_Profile.bscp -pk=3 -pp=********
Step 5 Upload zip file to destination: put D:\GMOpraExportTest\Staging\*.zip -bg
Steps 6: Post upload move zip file from source location on SFTP client to archive server
move fileName*.zip \\IP\Share
As you can see, there are multiple pieces which would need to work together. How can we combine this into a single script that can be run as a batch file. I am thinking from the POV of flow control and logging of the script process.
If anyone can provide any further guidance it will be appreciated