Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

plink won't return to command prompt

Tags:

bash

plink

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?

like image 598
user3252141 Avatar asked Jan 30 '14 12:01

user3252141


People also ask

How do I exit a plink session?

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.

How do I run plink on Windows?

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.

How does plink exe work?

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'.

What is the difference between PuTTY and plink?

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.


1 Answers

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.

like image 186
user3252141 Avatar answered Oct 17 '22 05:10

user3252141