2015-07-21 57 views
0

我從powershell腳本中調用psftp.exe,並正確下載指定的文件並正常運行,並將錯誤(如下所示)引發到命令行輸出,只要我可以說,整個過程沒有實質性的影響。與Powershell運行psftp時出錯

.\psftp.exe : Looking up host "hostname.com" 
At line:2 char:1 
+ .\psftp.exe 'hostname.com' -l 'username' -pw 'password ... 
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
    + CategoryInfo   : NotSpecified: (Looking up host "hostname.com":String) [], RemoteException 
    + FullyQualifiedErrorId : NativeCommandError 

Connecting to <HostIP> port <PortNo.> 
Server version: <Version> 
Using SSH protocol <Version> 
We claim version: <Version> 
Host key fingerprint is: 
<key> 
Using username "<username>". 
Attempting keyboard-interactive authentication 
Access granted 
Opening session as main channel 
Opened main channel 
Started a shell/command 
Sent EOF message 
Server sent command exit status 0 
Disconnected: All channels closed 

有誰知道這是什麼錯誤提示。當然,如果任何通過的憑據都是錯誤的,會話將無法正確連接並下載文件?

的腳本如下的完整性:

.\psftp.exe 'hostname.com' -l 'username' -pw 'Pass' -P 'portNo' -v -b 'GetFiles.txt' # -be -bc 

基於標記爲解決方案的反應,我已經修改爲 (.\psftp.exe 'hostname.com' -l 'username' -pw 'Pass' -P 'portNo' -v -b 'GetFiles.txt') 2> $null

回答

1

看起來像被寫入stderr所有詳細信息(容易確認通過在末尾運行與2> $null相同的命令)。在正常的PowerShell.exe中它不應該是可見的,ISE將封裝在異常中顯示爲標準錯誤的任何東西(正如您已經注意到的那樣)。

您在PowerShell ISE中運行psftp.exe嗎?如果是的話,你可能想用git in ISE類似的問題。

+0

我在這個例子中使用了powershell ISE。儘管不完全確定原因,但在結尾添加2> $ null似乎已經完成了這個訣竅......猜猜看是否有邊閱讀。非常感謝。 – ricky89