On 13 Nov 2007 at 19:11, Marco wrote:

> Hi...
Hi
 
> Can someone help me on this? Actually I can get the dara from the
> system()...But it shows "0" when I print the $result...How can I
> assign the system() to $result ?....Thanks...
> 
> here below is the code...
> 
> $inact = "cat /proc/meminfo | grep -w Inactive | sed 's/^.*Inactive: //
> g' | sed 's/kB//'";
> $result = system(cat /proc/meminfo | grep -w Inactive | sed 's/
> ^.*Inactive: //g' | sed 's/kB//');
> print $result;

I hesitate....I'm sure all the cat/grep/sed can be done in perl. 
There are probably modules that will do exactly what you want...but 
this works for me:


#!/usr/bin/perl

use strict;
use warnings;

# Ensure all the command is on one line or you get a shell error.
my $inact = "cat /proc/meminfo | grep -w Inactive | sed 
's/^.*Inactive: // g' | sed 's/kB//'";

my $result = system($inact);
print $result;

>1256480



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


Reply via email to