Finally, I was able to get this work to work.
set sh = CreateObject("WScript.Shell")
set fileExec = sh.Exec("C:\PuTTY_Folder\PLINK.EXE -pw password username@region find /filePickLoc/dir1 -name *batchID* -mmin -10 -type f")
filesStr = fileExec.StdOut.ReadAll
filesStr = Left(filesStr, Len(filesStr) - 1)
filesArray = Split(filesStr, vbLF)
createScriptFile folderPath, arr, "filePickLoc/dir1"
sh.Run "C:\PuTTY_Folder\PSFTP.EXE -b folderPath\Script.txt username@region -pw password", 7, True
set fileExec = Nothing
set sh = Nothing
C createScriptFile, I create a file .txtat runtime that PSFTP uses to transfer files.
Function createScriptFile(folderPath, files, loc)
set oFSO = CreateObject("Scripting.FileSystemObject")
set oFile = oFSO.CreateTextFile(folderPath & "\Script.txt", true)
oFile.write "lcd " & folderPath & " " & vbCrLf
oFile.write "cd /" & vbCrLf
For Each x In files
oFile.write "get " & x & " " & vbCrLf
Next
oFile.write "bye"
oFile.Close
set oFile = Nothing
set oFSO = Nothing
End Function
source
share