开发者

How can I redirect program output using libssh2?

I'm using libssh2 for a C++ program in a Linux environment and so far I'm able to start a program on a开发者_运维技巧 remote machine using libssh2_channel_exec. However I'd like to redirect the program's output to the local machine (i.e. the output shall travel over ssh). I'd like to achieve the same goal of the following bash line:

$ ssh user@remote ls > local_file.txt

I cannot specify the > local_file.txt part the command parameter because the file must be written in the local machine and not in the remote one.

So, how can I redirect a remote program's output to the local machine?


you should use the libssh2_channel_read function to read the remote stdout:

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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜