> Hello,
> 
> I have some code that is using backticks, executing commands on the korn
> shell.(if that matters).  Most work as expected and i get the output
of the
> shell command assigned to the variable left of the argument, like with
this
> ls command and 'db2 connect' command.
> <snips>
>       $is_dump = `ls $root_path$env/LOGS/ | grep dump`;
> 
>       $db_con = `db2 connect to $env user $dbuser using $dbpass`;
>                 if ($db_con =~ /$env/) {
> <snips />
> 
> further down in my code i'm executing a shut down command and a start up
> command using the same method. and in each of these instances, i'm
> assigning the output of this command to the variable and adding it to the
> body of an email.
> <snips>
>       $stop_cmd = `./psadmin -p stop -d $env`;
>       $body .= $stop_cmd;
>       sleep 60;
>       $start_cmd = `./psadmin -p start -d $env`;
> <snips />
> the calls to the psadmin script prints to the shell and don't get assigned
> to the variable.  but they work exactly as expected.  Is there a
better way
> to capture this output?  i've tried some searching, but have not found
> which FM to R :).
> 

See James' suggestions about why it is a bad idea to do anything using
backticks except as a very last resort.  I am not familar with psadmin
but a guess would be that the messages you are seeing are getting dumped
to STDERR instead of STDOUT. You might try capturing them with the whole:

2>&1 

Strategy or you may want to look into using an open3 (yikes),

perldoc perlipc
perldoc IPC::Open3

HTH,

http://danconia.org

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to