/ Published in: C++
How few lines does we need?
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
#include "exec_helper.h" #include <conio.h> #include <iostream> #include <boost/bind.hpp> #include <boost/thread.hpp> void read_thread(exec_helper& exec){ std::vector<char> buf(8192); std::size_t len; while(exec.is_active()) { len = exec.read(buf); if(len > 0) { std::cout.write(&buf[0], len); } } } int main(int argc, char* argv[]) { exec_helper ssh_exec; ssh_exec.set_exec_path("plink.exe"); ssh_exec.set_exec_args("-ssh 192.168.1.3 -l admin -pw password"); ssh_exec.start_exec(); boost::thread read(boost::bind(&read_thread, boost::ref(ssh_exec))); while(ssh_exec.is_active()) { int ch = _getch(); ssh_exec.write((char *)&ch, 1); } read.join(); return 0; }