[wplug] perl help

Ryan W. Frenz rfrenz at andrew.cmu.edu
Sun Feb 15 16:46:11 EST 2004


John Harrold wrote:

>Sometime in February Ryan Frenz assaulted the keyboard and produced:
>
>| I'm executing the program using 'system'.  But what I want to do is after
>| the command is executed remotely, get the pid of that command.  I'm trying
>| to append '|ps' to the ssh command, and it prints the output to stdout.
>| Is there a way I can capture this output in the perl script (without
>| showing it to the user) and still allow the user to enter the ssh
>| password?
>| 
>| The current script:
>| 
>| # !perl
>| 
>| $prog = $ARGV[0];
>| $label = $ARGV[1];
>| $machine = $ARGV[2];
>| 
>| system ( "ssh $machine \"$prog | ps\"");
>
>the only way i think you can get a pid, i believe, is to fork the process.
>perldoc -f fork, should give you a man page on it. i don't know how useful
>this will be since you want the user to be interactive with the program.
>
>perhaps someone more familiar with forking processes could help out.
>  
>
Well, what I can do is run 'ps' after the program is launched (via 
<program> | ps &).  The problem is that I want to launch a <program> 
that runs for awhile, but I want ssh to exit as soon as it is launched 
and ps is run.  I can do this locally by simply running "<program>&", 
but this doesn't work with SSH.  Does anyone know how I can specify a 
program to SSH on the command line and have it launch the process and 
exit immediately?




More information about the wplug mailing list