PSFTP批量输出重定向到本地日志文件

时间:2017-01-20 15:23:09

标签: vbscript sftp batch-processing psftp

我已经检查了很多不同的地方来解决这个问题,看起来很基本,但是当我尝试它时,事情就不喜欢我了。

我正在编写执行psftp.exe的vbscript,登录到远程SFTP站点,并抓取属性文件中引用的文件。

目标是将输出重定向到本地日志文件。这是vbs:

Public Sub execute(sftp)

    if sftp.privateKey <> "" Then

        cmd =   ".\psftp.exe "  _
            & " -l " & sftp.user _
            & " -P " & sftp.port _
            & " -i " & sftp.privateKey _
            & " " & sftp.name _
            & " -bc " & propFileName _
            & " -v -bc >> D:\SFTP_Jobs\logFile.txt"

        msgBox "Executing: " & ".\psftp.exe "  _
            & " -l " & sftp.user _
            & " -P " & sftp.port _
            & " -i " & sftp.privateKey _
            & " " & sftp.name _
            & " -bc " & propFileName _
            & " -v -bc >> D:\SFTP_Jobs\logFile.txt"


    Else

        cmd =   ".\psftp.exe "  _
            & sftp.name _
            & " -pw " & pw _
            & " -b " & PropFileName _
            & " -v -bc >> D:\SFTP_Jobs\logFile.txt"

        msgBox "Executing: " & ".\psftp.exe "  _
            & sftp.name _
            & " -pw XXXXXXXX" _
            & " -b " & PropFileName _
            & " -v -bc >> D:\SFTP_Jobs\logFile.txt"
    End If



    Dim TheShell: Set TheShell = WScript.CreateObject("WScript.Shell")
    TheShell.Run(cmd),0 , True
    set TheShell = Nothing


End Sub     'execute

此cmd最终看起来像

psftp.exe theBankIworkFor@ftp.oneOfOurVendors.com -pw thePw -b batchfile.properties -v -bc > D:\SFTP_Jobs\logFile.txt"

此命令一直正常工作,直到我在-v选项后添加了所有内容...

如果有关于此事的非常明显的话,我会事先道歉

0 个答案:

没有答案