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: 9.5.0.68 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 at 02:28

yerzhik's gravatar image

yerzhik
1


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");

link

answered Jul 04 at 12:08

chilkat's gravatar image

chilkat ♦♦
12.7k317362463

Your answer
toggle preview

Follow this question

By Email:

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

By RSS:

Answers

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

Tags:

×105
×11

Asked: Jun 29 at 02:28

Seen: 189 times

Last updated: Jul 04 at 12:08

powered by OSQA