문제

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

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top