Reputation: 191
I try to execute a bash script via plink. Script looks something like this:
echo "@ Starting process..."
./bin/process "process.cfg" &
disown %1
echo "@ Done!"
When i execute this script in a terminal on linux, everything works fine. After the "Done!" line I get a command prompt (as expected).
Now when I run this script via plink, the output stops afyer the "Done!" line, but plink won't return to the command prompt and "hangs" until +c.
The script is placed in a file and given to plink with the -m parameter
I tried addind 'logout', 'exit', 'set -e' at the end of the script, but it doesn't help. Also adding -batch, -T or -N to the plink command brought no success.
Any ideas on how to fix this?
Upvotes: 11
Views: 12051
Reputation: 7197
plink.exe -P PORT_NUM -v USERNAME@HOST_IP -pw PASSWD "COMMAND >/dev/null &"
&
would move your process to the background > /dev/null
allows your command run silently by getting stdout/stderr to output to a dummy null device note: the shell command is wrapped in "double quotations"
Upvotes: 5
Reputation: 191
Ok, it seems I had to detach stdout/err from the terminal. In a normal terminal this wouldn't matter ofcourse, but plink remained in a "busy" state because of this.
So, inside my bash script (which executed the command) I had to change:
./bin/process "process.cfg" &
to:
./bin/process "process.cfg" /dev/null 2>&1 &
plink now returns the correct "finished" state at the end of the bash script.
Upvotes: 8
Reputation: 14523
Plink has a -batch
parameter which disable all interactive prompts. It may be what you need here to avoid hanging until ctrl-C.
Upvotes: 0