Chipwiz_Ben has asked for the wisdom of the Perl Monks concerning the following question:
I have a perl CGI script that grabs a bunch of variables from a user before executing another perl script with those variables. This execution is forked and backgrounded so that the browser doesn't hang waiting for the script to finish. The exit status of ./processor.pl doesn't matter to the browser user as it writes its output to a database, so I want to run it and detach from it immediately.
The following two are how the CGI script executes the job processor.
This works:
exec "./processor.pl -j $Trigger_Job -u $Captured_User_Name -P $Captured_Password > /dev/null 2>&1 &";
This does not:
exec "echo $Captured_Password | ./processor.pl -j $Trigger_Job -u $Captured_User_Name > /dev/null 2>&1 &";
The problem is that if I use the first example, the user's password shows up in ps or top as it's passed as a parameter which is why I'm trying to echo it instead.
Here's how the ./processor.pl is capturing the input (for the echo):
use Term::ReadKey; ReadMode 4; $User_Password = <STDIN>; ReadMode 0;
If I run echo bla | ./processor.pl -j 12 -u blabla in a terminal, it works, so I know that the echo'd password is being caught correctly in processor.pl. So my suspicion is with exec not handling the pipe correctly or something similar. Or perhaps a TTY issue - but I don't really know.
Why doesn't the echo work as I expect it to (like in bash), and how should I actually handle this password passing?
Thanks,
Ben
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: exec, echo and pipe
by andal (Hermit) on Apr 01, 2016 at 07:20 UTC | |
|
Re: exec, echo and pipe
by Anonymous Monk on Apr 01, 2016 at 02:55 UTC | |
|
Re: exec, echo and pipe
by morgon (Priest) on Apr 01, 2016 at 17:51 UTC | |
by afoken (Chancellor) on Apr 02, 2016 at 20:54 UTC | |
by morgon (Priest) on Apr 03, 2016 at 01:44 UTC | |
by afoken (Chancellor) on Apr 04, 2016 at 20:06 UTC |