Hi all,

How do I parse or evaluate the output of UNIX commands?

For example, in UNIX scripts, I can run filesystem=`df -k | awk -F"" ' { print
$6 }'` to check for the mount points.

How do I achieve the same in Perl? That is, I tried:

#!/usr/bin/perl
$x=system 'df -k';
print "============================= \n";
print $x . "\n";

And I am hoping that I can same the results of the df -k output into some kind
of variable that I can then parse and arrange into some format to check for
what logical volumes is mounted into what filesystems etc.

But x gives I believe the result of whether running the system command is
successful or not.

Maybe I can just simply run system 'df -k', re-direct that into some output file
and then parse it using OPEN-CLOSE filehandles. Is there any easier way of doing
this?

I am not just wanting to do this for the df -k command but also for executing ls
-l | wc -l maybe and some other UNIX commands.

Any advise will be very much appreciated. Thanks ....




-- 
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