Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Grab output of file called by system() 1

Status
Not open for further replies.

edpatterson

IS-IT--Management
Feb 24, 2005
186
I need to capture the output of a DOS executable into a perl script.

'executable' could be any valid DOC exe|com file that writes to the screen.

I tried $response = system('executable'); but only recived the errorlevel of the apps.
Code:
my $response
$servers = qw(one two three four five);
foreach($servers){
  $response = system('executable');
  if($response == 'string'){
    do_someting();
  }else{
    do_something_else();
}
Thanks,
 
Code:
$responce = `executable`;

OR

$responce = qx/executable/;
 
Use backticks or qx() if you want to capture the output.

Also, the string comparison operator is eq, not ==. The latter is for comparing numbers, not strings.

 
<thunk> Sound of someone hitting them selves in the forehead.

Thanks, I knew that, why couldn't I *remember* it is the question?

I must be getting senile.

Ed
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top