login about faq

I want to send and execute commands on a unix server.

when I send the command I would like to update the user as to the status of the job. Even being able to say 'The job is still running' would be helpful. Is there a way to do this?

asked Mar 03 '17 at 14:02

bcgrossman's gravatar image

bcgrossman
1


There are two ways to execute remote commands on a server:

  1. The rexec command (see https://linux.die.net/man/1/rexec ). This is what the SendReqExec method does. (In other words, Chilkat internallly is running the remote command in the same way as rexec.) The output of the command goes to stdout, which is sent back to the SSH client on the channel.
  2. Establish an SSH shell session and send commands on stdin (where a LF or CRLF trigger execution of the command line, just like when you're typing at a terminal) and get results on stdout. Again, the output is sent back to the SSH client on the channel.

Let's say you have a command that takes a long time, and at the very end prints "Command Completed" to stdout before it exits. In both of the above cases, after starting the remote command, your program could try to receive the stdout by calling ChannelReadAndPoll. Nothing would be received until the very end when the "Command Completed" is emitted. There's really no way to know the status of your command -- unless you bake into your command something that periodically emits the status to stdout.

The solution is to modify your command (if possible) so that it emits status output to stdout as it runs. Then your SSH client program can receive the channel output and report the status.

link

answered Mar 06 '17 at 09:06

chilkat's gravatar image

chilkat ♦♦
12.8k318385543

Thank you.

link

answered Mar 06 '17 at 11:59

bcgrossman's gravatar image

bcgrossman
1

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:

×2
×2

Asked: Mar 03 '17 at 14:02

Seen: 620 times

Last updated: Mar 06 '17 at 11:59

powered by OSQA