1835421 Members
2609 Online
110078 Solutions
New Discussion

Re: Convert Bash to Perl

 
SOLVED
Go to solution
Ricardo Bassoi
Regular Advisor

Convert Bash to Perl


Hi All,

How to convert this script to Perl, anyone has an idea ?

Regards,

Bassoi
If you never try, never will work
1 REPLY 1
H.Merijn Brand (procura
Honored Contributor
Solution

Re: Convert Bash to Perl

Why?

Assuming you have perl5.6.1 or up, this could be a start. Warning: I did not even check the syntax :)

#!/your/path/to/perl

use strict;
use warnings;

# This shell script check the file system increasing size.
# Put it in the cron for best results ( each 20 minutes is a good idea !!! )
# Read the File System

open LOG, ">>check_fs.err" or die "check_fs.err: $!";
for (`df -k`) {
my ($fs, $sz, $used, $avail, $pct, $mnt) = (m/^(\S+)\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+)%\s+(\S+)/) or next;
if ($pct > 89) {
print LOG localtime time;
print LOG " The filesystem $fs is at $pct% !!!. Please check the file\n";
#mail -d rbassoi@yahoo.com.br < check_fs.err
#cat check_fs.err | mail -s " Warning ! / with $VALUE1%" mixilo@yahoo.com
#cat check_fs.err | mail -s " Warning ! / with $VALUE1%" awcogo@alcatel.com.br
}
}
close LOG or die "check_fs.err


Mind that this is only a hint. We're not here to do your job.

Enjoy, have FUN! H.Merijn
Enjoy, Have FUN! H.Merijn