我正在尝试在Unix directrory中搜索文件,并使用PSFTP将它们复制到我的本地Windows机器上。
我正在运行以下命令:
sh = CreateObject("WScript.Shell")
sh.Run "C:\PuTTY_Folder\PSFTP.EXE -b C:\PuTTY_Folder\script.txt user@host -pw password"
script.txt
档案:
lcd C:\Regression
cd /b2/batch/ABCD
find . -mtime 1 -name "*_000000022_*" -type f # I want to find the files and copy them to my local windows machine.
bye
find
命令无法与PSFTP
一起使用。
它说:unknown command find.
我想我可以使用mget
复制多个文件,但不知道如何搜索和复制。
请建议。
链接到PSFTP文档:
http://the.earth.li/~sgtatham/putty/0.60/htmldoc/Chapter6.html
答案 0 :(得分:1)
我终于能够把这件事搞定了。
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
使用createScriptFile
,我在运行时创建一个.txt
文件,PSFTP正在使用该文件来传输文件。
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