【问题标题】:How can I redirect program output using libssh2?如何使用 libssh2 重定向程序输出?
【发布时间】:2011-10-12 10:37:48
【问题描述】:

我在 Linux 环境中将 libssh2 用于 C++ 程序,到目前为止,我能够使用 libssh2_channel_exec 在远程机器上启动程序。但是我想将程序的输出重定向到本地机器(即输出将通过 ssh 传输)。 我想实现以下 bash 行的相同目标:

$ ssh user@remote ls > local_file.txt

我无法将> local_file.txt 部分指定为command 参数,因为该文件必须写入本地计算机而不是远程计算机。

那么,如何将远程程序的输出重定向到本地机器?

【问题讨论】:

    标签: linux libssh2


    【解决方案1】:

    您应该使用 libssh2_channel_read 函数来读取远程标准输出:

    http://www.libssh2.org/libssh2_channel_read.html

    【讨论】:

    • 我不再需要这个了,但很高兴知道。感恩 ;)
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-01-16
    • 2016-03-17
    • 2010-11-05
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多