peerplays-fc/tests/ssh.cpp

46 lines
1.1 KiB
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>
2012-11-09 05:31:39 +00:00
//#include <iostream>
2012-11-09 02:18:35 +00:00
int main( int argc, char** argv ) {
try {
2013-03-01 23:56:06 +00:00
slog( "create ssh client" );
2012-11-09 02:18:35 +00:00
fc::ssh::client c;
2013-03-01 23:56:06 +00:00
c.connect( "dlarimer", "rapture", "10.10.10.112" );
slog( "connected" );
fc::ssh::process proc = c.exec( "/bin/cat -u" );
slog( "proc!");
fc::string hello( "hello.............." );
hello += hello;
hello += hello;
hello += hello;
hello += hello;
hello += hello;
hello += "\n";
/*
hello += hello2;
*/
fc::string line;
proc.in_stream().write(hello.c_str(), hello.size() );
fc::getline( proc.out_stream(), line );
fc::cout<<line<<"\n";
2012-11-09 03:02:07 +00:00
while( !proc.out_stream().eof() ) {
fc::cout<<line<<"\n";
2013-03-01 23:56:06 +00:00
proc.in_stream().write(hello.c_str(), hello.size() );
proc.in_stream().flush();
fc::getline( proc.out_stream(), line );
2012-11-09 03:02:07 +00:00
}
fc::cout<<"result: "<<proc.result()<<"\n";
2013-03-01 23:56:06 +00:00
/*
while( true ) {
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;
}