【问题标题】:error when running psftp with Powershell使用 Powershell 运行 psftp 时出错
【发布时间】:2015-10-11 03:43:33
【问题描述】:

我正在从 powershell 脚本调用 psftp.exe,虽然它正确下载了指定的文件并按预期运行,但错误(如下)被抛出到命令行输出,据我所知没有任何材料对整个过程的影响。

.\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&gt; $null

【问题讨论】:

    标签: powershell putty


    【解决方案1】:

    看起来所有详细消息都写入了 stderr(通过运行带有 2&gt; $null 的相同命令很容易确认)。

    在“正常”的 PowerShell.exe 中它不应该是可见的,ISE 将封装任何在异常中出现在标准错误中的内容(正如您所注意到的)。

    您是否在 PowerShell ISE 中运行 psftp.exe?如果是,您可能想使用我建议的一种技术来解决git in ISE 的类似问题。

    【讨论】:

    • 我在这个例子中使用了 powershell ISE。最后添加 2> $null 似乎已经成功了,尽管不完全确定为什么......猜猜一些侧面阅读是在卡片上。非常感谢。
    猜你喜欢
    • 1970-01-01
    • 2020-04-22
    • 1970-01-01
    • 2020-08-14
    • 2018-05-12
    • 2014-05-15
    • 2020-02-05
    • 2014-07-23
    相关资源
    最近更新 更多