in reply to getting output from backticks

You should try system - unlike backticks, it does not gather the executed program's STDOUT, but unlike backticks, it does gather the program's exit value and stores it in $?

UPDATE: listen to bikeNomad - STDERR is your friend here :)

Jeff

R-R-R--R-R-R--R-R-R--R-R-R--R-R-R--
L-L--L-L--L-L--L-L--L-L--L-L--L-L--
  • Comment on (jeffa) Re: getting output from backticks

Replies are listed 'Best First'.
Re: (jeffa) Re: getting output from backticks
by melguin (Pilgrim) on Jul 19, 2001 at 02:59 UTC
    I have tried that, but got exactly the same results: $? is 0 before the call. After the call it is 256 if there was an error and 0 if there wasn't.

    Thanks though. Any other ideas? From what I've read in the documentation and from previous questions on this site, that sould be right.

    conan.

      Well the 256 result code should track back to a more specific error - if you check out the documentation for mount - you may find out more precisely what that error means.

      As for system Vs. backticks etc. - when I have to use one or the other - I generally try this sub:
      # SubRoutine: sysrun # # Run System Command sub sysrun { my ($command) =@_; my $ret_code; $ret_code = system("$command"); if ( $ret_code == 0 ) { # Job suceeded $ret_code = 1; } else { # Job Failed $ret_code = 0; } return ($ret_code); }
      While this doesn't store the return code from the system call, it does allow you to treat the system call with logical operators like any other perl program

      Also, the return_code can easily be logged if there is an error from this sub.
      game(Wookie,opponent) eq 'Wookie' ? undef $problem : remove_limbs(arms,opponent);