peerplays-fc/tests/ssh.cpp

31 lines
762 B
C++
Raw Normal View History

2012-11-09 02:18:35 +00:00
#include <fc/ssh/client.hpp>
#include <fc/exception.hpp>
#include <fc/log.hpp>
#include <fc/iostream.hpp>
#include <iostream>
int main( int argc, char** argv ) {
try {
2012-11-09 03:02:07 +00:00
// if( argc < 3 ) {
// fc::cout<<argv[0]<<" local_path remote_path\n";
// return -1;
// }
2012-11-09 02:18:35 +00:00
fc::cout<<"password: ";
std::string pw;
std::cin>>pw;
fc::ssh::client c;
c.connect( "dlarimer", pw, "localhost" );
2012-11-09 03:02:07 +00:00
fc::ssh::process proc = c.exec( "/bin/ls" );
while( !proc.out_stream().eof() ) {
fc::string line;
fc::getline( proc.out_stream(), line );
fc::cout<<line<<"\n";
}
fc::cout<<"result: "<<proc.result()<<"\n";
// c.scp_send( argv[1], argv[2] );
2012-11-09 02:18:35 +00:00
} catch ( ... ) {
wlog( "%s", fc::except_str().c_str() );
}
return 0;
}