Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - spino

Pages: [1]
1
Hi.

Thanks for the suggestion. I try using GetReceivedData and it works!

Best,

2
Hi,

I'm running a command that outputs null characters (cat /proc/$some_ip/cmdline). The issue is that when I get the string using getReceivedText, the string is chopped or incomplete (because c/c++ strings are finished using the null character).

So, doesn't Chilkat offers a way to get the entire output?

In the reproducible bellow, I'm expecting:
"Step 1"
"Hi"
"Step 2"

But only get "Step 1"

#include <CkSsh.h>
#include <stdio.h>

int main()
{
  CkSsh ssh;

  bool status = ssh.UnlockComponent(...);
  if (!status) {
    printf("%s\n", ssh.lastErrorText());
    return -1;
  }

  status = ssh.Connect("host", 22);
  if (!status) {
    printf("%s\n", ssh.lastErrorText());
    return -1;
  }

  status = ssh.AuthenticatePw("user", "pass");
  if (!status) {
    printf("%s\n", ssh.lastErrorText());
    return -1;
  }

  const char* cmd = "echo 'Step 1'; echo -e '\\0 Hi'; echo 'Step 2'";
  printf("%s\n", cmd);
  const char* stdOut = ssh.quickCommand(cmd, "unicode");
  if (!ssh.get_LastMethodSuccess()) {
    printf("%s\n", ssh.lastErrorText());
    return -1;
  }

  printf("stdOut: '%s'\n", stdOut);

  ssh.Disconnect();

  return 0;
}



3
Hi,

I wonder if it is possible to get the stderr (GetReceivedStderrText) separately from stdout (GetReceivedText)?

I'm trying to do this by:

 1. For CkSsh object, I do "ssh->put_StderrToStdout(false);"

 2. To request the shell, I do "int channel = ssh->QuickShell();"

 3. To get the output I do:

Code: [Select]
*std_out = ssh->getReceivedText(channel, "ansi");
if (!ssh->get_LastMethodSuccess()) {
    cerr << "error" << std::endl; 
}

*std_err = ssh->getReceivedStderrText(channel, "ansi");
if (!ssh->get_LastMethodSuccess()) {
    cerr << "error" << std::endl;
}

However, I just get both stdout and stderr together in getReceivedText. Please notice that a similar approach works for connections where I don't request a shell/pty (a.k.a using ssh->SendReqExec).

Thanks for the time and help.

Pages: [1]