mirror of
https://github.com/ultimatepp/ultimatepp.git
synced 2026-07-11 22:03:01 -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
bbc2096e95
commit
534f80a85f
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());
|
||||
}
|
||||
12
reference/SshExec/SshExec.upp
Normal file
12
reference/SshExec/SshExec.upp
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
description "Demonstrates basic SSH remote command execution .\377";
|
||||
|
||||
uses
|
||||
Core,
|
||||
Core/SSH;
|
||||
|
||||
file
|
||||
SshExec.cpp;
|
||||
|
||||
mainconfig
|
||||
"" = "";
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue