Announcement

Collapse
No announcement yet.

How to use dumpe2fs in script

Collapse
This topic is closed.
X
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    How to use dumpe2fs in script

    I am trying to write a perl program to check on various partition parameters. I use the dumpe2fs command as follows:

    #!/usr/bin/perl

    $cmd =
    sprintf( "sudo dumpe2fs -h %s | grep -i \'mount count\' 2>/dev/null" , "/dev/sda6");

    @res = `$cmd`;

    exit;

    The darn thing ALWAYS prints out the header line:

    $ dumpe2fs-what.pl
    dumpe2fs 1.42.5 (29-Jul-2012)

    This completely messes up the output from my perl program. Is there no way to shut the thing up? Or am I confused again.
    Last edited by joneall; Oct 28, 2013, 03:32 AM. Reason: Pb resolved
    'I must have a prodigious quantity of mind; it takes me as much as a week sometimes to make it up.' Mark Twain

    #2
    If you wish to suppress STDERR output for the dumpe2fs command, you'll want to put the redirection before the pipe (simplified the command for clarity, add the bits to make it complete):
    dumpe2fs 2>/dev/null | grep

    Alternatively you could send STDERR to STDOUT and let grep weed it out:
    dumpe2fs 2>&1 | grep
    Last edited by kubicle; Oct 28, 2013, 03:27 AM.

    Comment


      #3
      Of course. Thank you.
      'I must have a prodigious quantity of mind; it takes me as much as a week sometimes to make it up.' Mark Twain

      Comment

      Working...
      X