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?
If you are running plink then at the end of your command, create a new line and use the command EXIT and that should do it.
Windows. You will need to have Python (> 2.4), Tk (>= 8.4), and Tkinter installed to run plink; for instance, if you are using Debian or Ubuntu, just install the package “python-tk”. This installs a shell-command called “plink” which starts PLink.
Plink is a command line application. This means that you cannot just double-click on its icon to run it and instead you have to bring up a console window. In Windows 95, 98, and ME, this is called an 'MS-DOS Prompt', and in Windows NT, 2000, and XP, it is called a 'Command Prompt'.
Use PuTTY for interactive SSH session from your Windows to Linux Servers. Use Plink for non-interactive SSH session to execute remote linux commands for automation purpose from your Windows.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With