mirror of
https://github.com/ultimatepp/ultimatepp.git
synced 2026-09-09 03:24:59 -06:00
Added a console-based SshExec example.
git-svn-id: svn://ultimatepp.org/upp/trunk@12165 f0d560ea-af0d-0410-9eb7-867de7ffcac7
This commit is contained in:
parent
0c94f1e3d3
commit
895fa89ab2
2 changed files with 39 additions and 0 deletions
27
reference/SshExec/SshExec.cpp
Normal file
27
reference/SshExec/SshExec.cpp
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
#include <Core/Core.h>
|
||||
#include <Core/SSH/SSH.h>
|
||||
|
||||
using namespace Upp;
|
||||
|
||||
CONSOLE_APP_MAIN
|
||||
{
|
||||
StdLogSetup(LOG_COUT|LOG_FILE);
|
||||
// Ssh::Trace();
|
||||
|
||||
const char *cmd = "ls -l /pub/example";
|
||||
String cout, cerr;
|
||||
|
||||
SshSession session;
|
||||
if(session.Timeout(30000).Connect("demo:password@test.rebex.net:22")) {
|
||||
SshExec exec = session.CreateExec();
|
||||
if(exec(cmd, cout, cerr) >= 0) {
|
||||
LOG("Stdout:\n" << cout);
|
||||
LOG("Stderr:\n" << cerr);
|
||||
LOG("Exit code: " << exec.GetExitCode());
|
||||
}
|
||||
else
|
||||
LOG(exec.GetErrorDesc());
|
||||
}
|
||||
else
|
||||
LOG(session.GetErrorDesc());
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue