There are several ways to do this :
You can try :
+++++++++++++++++++++++++
# To capture into an array :
# note : next line has backticks NOT single quotes.
@command_output = `ipconfig 2>&1` ;
print "@command_output" ;
# then process as standard array.
+++++++++++++++++++++++++
If you need to process line by line :
+++++++++++++++++++++++++
$command2run = "ipconfig" ;
open (CMDOUTPUT, "$command2run 2>&1 |" ) ;
while (!eof(CMDOUTPUT)) {
$command_output_line = <CMDOUTPUT> ;
# display line on screen :
print ("$command_output_line") ;
}
close CMDOUTPUT ;
+++++++++++++++++++++++++
Note : The '2>&1' associated with the command is optional ;
It's here only to specify that we want to capture the system STDERR as well
as STDOUT (useful when command fails !)
_____________________________________________
Bruno Bellenger
Senior Network/Systems Administrator
> -----Original Message-----
> From: Kan, Yu-Ting [SMTP:[EMAIL PROTECTED]]
> Sent: Wednesday, May 02, 2001 7:46 AM
> To: ActivePerl
> Subject: Get the result from "system" Call
>
> Dear all,
>
> When I am using the "system" command
>
> system 'tail','-n', $get, $Alarm_File;
>
> The result always display in the monitor. It is failed to assign the
> result
> into a variable.
>
> Is it a methos to use its result inside the same program?
>
> Thanks a lot
>
> Kan
> _______________________________________________
> ActivePerl mailing list
> [EMAIL PROTECTED]
> http://listserv.ActiveState.com/mailman/listinfo/activeperl
_______________________________________________
ActivePerl mailing list
[EMAIL PROTECTED]
http://listserv.ActiveState.com/mailman/listinfo/activeperl