""Mr. Shawn H. Corey"" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> On Tue, 2006-06-06 at 18:59 +0800, joseph wrote:
>> All,
>>
>> Just like to ask for correction on what's wrong with my script it gives
>> spit
>> out this error when i run it.
>>
>> Unsuccessful open on filename containing newline at disksize.pl line 8.
>> Can't open file No such file or directory
>>
>> But it runs without this error whenever i feed it up when an existing
>> file
>> output by df-h.
>> ex:## open(FL,"path/toactual/file") or die "blabalha";
>> Does this mean it can't trap the output of `df-h`?
>>
>> Here's the script###
>>
>> #!/usr/bin/perl
>>
>> use strict;
>> use warnings;
>>
>> chomp(my $output_file = `df -h`);
>
> $output_file =~ s/\r//g;
> # chomp only removes linefeed characters \n
>
> # BTW, there is no such thing as a newline;
> # it is either a linefeed: \n ASCII LF 0x0A
> # or a carriage return: \r ASCII CR 0x0D
I still have to dig on this topic, i assume it works the same way like the
sample on a book like this # chomp($file = `date`);
>
>>
>> open(FL,"$output_file") or die "Can't open file $!\n";
>
> ... or die "cannot open file '$output_file': $!\n";
> # print out the contents so you can see exactly what it contains.
Unsuccessful open on filename containing newline at disksize.pl line 8.
Can't open file: Filesystem Size Used Avail Use% Mounted on
/dev/cciss/c0d0p7 1.9G 215M 1.6G 12% /
/dev/cciss/c0d0p8 12G 9.8G 1.4G 87% /backup
/dev/cciss/c0d0p1 96M 16M 76M 17% /boot
/dev/cciss/c0d0p2 38G 24G 12G 66% /home
none 1.9G 0 1.8G 0% /dev/shm No such file or
directory
#It's present right?
Thanks for input.
>
>> my @list;
>> my %disk;
>> my($label,$size,$use,$avail,$percent,$mounted,$partition,$usage);
>> while(<FL>) {
>> ($label,$size,$use,$avail,$percent,$mounted) = split(/\s+/, $_);
>> push @list,$mounted,$percent;
>> }
>>
>> %disk =(@list);
>> delete $disk{"Mounted"};
>>
>>
>>
>> foreach (sort keys %disk) {
>> my $value = $disk{$_};
>> print "\t $_ => $value \n";
>> }
>
>
>
> --
> __END__
>
> Just my 0.00000002 million dollars worth,
> --- Shawn
>
> "For the things we have to learn before we can do them, we learn by doing
> them."
> Aristotle
>
> * Perl tutorials at http://perlmonks.org/?node=Tutorials
> * A searchable perldoc is at http://perldoc.perl.org/
>
>
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>