in reply to Formatted Text

You have a few mistakes in your code -
1) you openned DISKSPACE for writing yet you are reading from it.
2) you had typo/spelling mistakes in the code.
3) you should use qx or `` to capture output from df.

I have written a demo on how to format df output according to your format.

#!/usr/bin/perl -w format DISKSPACE = ====================== |@<<<<<<<<<<<<<<<<<<<| $FileSystem |@<<<<<<<<<<<<<<<<<<<| $kbytes |@<<<<<<<<<<<<<<<<<<<| $used |@<<<<<<<<<<<<<<<<<<<| $avail |@<<<<<<<<<<<<<<<<<<<| $capacity |@<<<<<<<<<<<<<<<<<<<| $Mounted_on ====================== . sub df_total { my @lines = split /\n+/, shift; open (DISKSPACE, ">spaceavail.txt") || die "Error opening file space +avail.txt"; for (@lines) { ($FileSystem, $kbytes, $used, $avail, $capacity, $Mounted_on) = sp +lit (/\s+/); write (DISKSPACE); } close (DISKSPACE) } my $result = `df -k`; df_total($result);

Replies are listed 'Best First'.
Re: Re: Formatted Text
by TekWannaBe (Initiate) on Jan 30, 2004 at 16:41 UTC
    Thanks Roger....I did attempt this but the code does the same thing, I do not get the output from df -k formatted in the file get no output to the file spaceavail.txt
      Interesting, are you sure? The code I posted has been tested and works for sure. Perhaps you can post your updated code here and let's see which part is not working.