Вопрос

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