login about faq

My aim is to make "cd /mydirpath" and run my program which was compiled before: "./a.out" Here is how I'm trying to make it:

const char *cmd1 = "cd /home/machinekit/projects";

char *cmd2 = "./a.out";

success = ssh.SendReqExec(channelNum, cmd1);    if (success != true) {      std::cout << ssh.lastErrorText() << "\r\n";         return;     }

    success = ssh.SendReqExec(channelNum, cmd2);    if (success != true) {      std::cout << ssh.lastErrorText() << "\r\n";         return;     }

The first command didn't return an error though the second one gives:

ChilkatLog: SendReqExec: DllDate: May 25 2017 ChilkatVersion: UnlockPrefix: Anything for 30-day trial Architecture: Little Endian; 64-bit Language: Visual C++ 2017 / x64 VerboseLogging: 0 sendReqExec: command: a.out reqExecCharset: ANSI channel: 100 commandQP: a.out Unexpected message type received in response to exec request. messageType: 96 --sendReqExec Failed. --SendReqExec --ChilkatLog

asked Jun 29 '17 at 02:28

yerzhik's gravatar image


Each command sent in SendReqExec is independent of others. (they are idempotent)

To accomplish what you want, you should make a single call to SendReqExec with a command that is a sequence of multiple commands.

See https://stackoverflow.com/questions/13077241/execute-combine-multiple-linux-commands-in-one-line

For example:

success = ssh.SendReqExec("cd /home/machinekit/projects && ./a.out");


answered Jul 04 '17 at 12:08

chilkat's gravatar image

chilkat ♦♦

Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here



Answers and Comments

Markdown Basics

  • *italic* or __italic__
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported



Asked: Jun 29 '17 at 02:28

Seen: 1,477 times

Last updated: Jul 04 '17 at 12:08

powered by OSQA