run command in background

Jan 19, 2012 at 9:47 AM


I am trying to do the following. Run a shell script that set some variables, and after that runs another script (a service) in the background.

My code is:

=== ===
var1 = x
./ &

=== ===
while (true); do
    echo "service running"

The problem is that RunCommand() doesn't ends until i kill "". Why? I run "" with RunCommand(), and that scripts end normally. The "" is detachend from it and sent to background.

Please help!
Regards Peter.

Jan 25, 2012 at 6:27 AM

Could someone answer to this???

Jan 25, 2012 at 1:32 PM



Sorry that you nobody reply to this problem yet. I personally not a UNIX person so dont really know what might be a problem.

All RunCommand does is passing the command to the default shell for execution, waits for it to finish and then exits.


I guess what you can try to do is to execute command asynchronously and see if helps you.




Jan 25, 2012 at 4:27 PM

Could it be that is still writing output to the shell, so RunCommand continues to listen until the shell is closed?

To test this theory, try something like this:



var1 = x
./ > /dev/null &

Jan 27, 2012 at 7:19 AM

Thanks for the help guys!

The asynchronous execution solved the problem. I don't understand why, becouse if I do the same with a normal ssh client (eg. putty), then the script ends normally and I can close the shell too.

The redirect to /dev/null dosen't works. Even if the "" dosen't writes to the console output, the connection still hangs.

Thank again!
Regards Peter.