File Upload and Download Automation
Author :
Babu Dhinakaran S
Blog :Linuxos4all
Date: 3/5/2012 7:34:00 AM
Set oFTPScriptFSO = CreateObject("Scripting.FileSystemObject")
Set oFTPScriptShell = CreateObject("WScript.Shell")
upFileName = "C:\Users\n1009932\Desktop\test.txt"
UserName = "Customer_name"
Password = "welcome123"
GateWayServer = "prepb2bgw01.jdadelivers.com"
sUpldCmd = """c:\Program Files (x86)\WinSCP\WinSCP.com"" -script=" & "C:\Users\n1009932\Desktop\upldfile.txt"
sDwnldCmd = """c:\Program Files (x86)\WinSCP\WinSCP.com"" -script=" & "C:\Users\n1009932\Desktop\dwnldfile.txt"
'WScript.Echo "run Command: " & sCmd
sReturn = oFTPScriptShell.Run(sUpldCmd,3,true)
'WScript.Echo "Run Return Value: " & sOut
Wscript.Sleep 1000
'Delete the file once it is uploaded.
If ( sReturn = 1) Then
If (oFTPScriptFSO.FileExists("C:\Users\n1009932\Desktop\test.txt")) Then
oFTPScriptFSO.DeleteFile("C:\Users\n1009932\Desktop\test.txt")
Else
'unable to delete the file Uploaded File
WScript.Quit (1)
End If
End If
sReturn = 0
'procedures to download the file and delete after that.
sReturn = oFTPScriptShell.Run(sDwnldCmd,3,true)
WScript.Sleep 1000
If ( sReturn = 1) Then
If (oFTPScriptFSO.FileExists("C:\Users\n1009932\Desktop\test.txt")) Then
WScript.Quit (0)
Else
'File hasn't downloaded, check manually.
WScript.Quit (2)
End If
End If
Set oFTPScriptShell = Nothing
Set oFTPScriptFSO = Nothing