在新的Linux Server(Red Hat Enterprise Linux Server release 5.7 (Tikanga))上配置磁碟空間警示的perl指令碼後,測試時報如下錯誤
[oracle@DB-Server scripts]$ ./disk_capatiy_alarm.sh
Can't locate Mail/Sender.pm in @INC (@INC contains: /usr/lib64/perl5/site_perl/5.8.8/x86_64-linux-thread-multi /usr/lib/perl5/site_perl/5.8.8 /usr/lib/perl5/site_perl /usr/lib64/perl5/vendor_perl/5.8.8/x86_64-linux-thread-multi /usr/lib/perl5/vendor_perl/5.8.8 /usr/lib/perl5/vendor_perl /usr/lib64/perl5/5.8.8/x86_64-linux-thread-multi /usr/lib/perl5/5.8.8 .) at /home/oracle/scripts/output/disk_sendmail.pl line 2.
BEGIN failed--compilation aborted at /home/oracle/scripts/output/disk_sendmail.pl line 2.
Perl指令碼disk_sendmail.pl 如下所示,其中使用了Mail-Sender郵件模組,
#!/usr/bin/perluse Mail::Sender;$sender = new Mail::Sender {smtp => 'xxx.xxx.xxx.xxx', from => 'xxx@xxx.com'};$sender->MailFile({to => 'xxx@xxx.com',cc=>'xxx@xxx.com ',subject => 'The server xxxx\'s Disk Capacity Alarm',msg => 'Dear All, The server xxxx disk capacity alarm ,please take action for it. many thanks!',file => '/home/oracle/scripts/output/diskdetail.txt'});
更多精彩內容:http://www.bianceng.cnhttp://www.bianceng.cn/Programming/extra/
出現這個錯誤是因為Perl沒有安裝Mail-Sender模組,安裝了此模組問題即可解決,Mail::Sender模組支援發送帶附件的郵件。可以使用下面幾種方式安裝
1:使用cpan安裝,要求伺服器能夠訪問外網,否則無法下載相關包。
cpan> install Mail::Sender
2:下載perl-Mail-Sender-0.8.16-1.el5.pp.noarch.rpm
下載地址:http://rpm.pbone.net/index.php3/stat/4/idpl/10370607/dir/redhat_el_5/com/perl-Mail-Sender-0.8.16-1.el5.pp.noarch.rpm.html
[root@DB-Server oracle]# rpm -ivh perl-Mail-Sender-0.8.16-1.el5.pp.noarch.rpm
warning: perl-Mail-Sender-0.8.16-1.el5.pp.noarch.rpm: Header V3 DSA signature: NOKEY, key ID 6971f6ac
Preparing... ########################################### [100%]
1:perl-Mail-Sender ########################################### [100%]
3: 下載安裝Mail-Sender-0.8.16.tar.gz 。這種方法我沒有實驗過,因為http://search.cpan.org/CPAN/authors/id/J/JE/JENDA/Mail-Sender-0.8.16.tar.gz 老是無法下載這個安裝包。
作者:瀟湘隱者
出處:http://www.cnblogs.com/kerrycode/