- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- perl script won't send any mails
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Discussions
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-10-2006 03:15 AM
11-10-2006 03:15 AM
I have this perl script, but it won't send any mails:
#!/usr/bin/perl -w
use strict;
use warnings;
my $PingHost = "192.168.0.11";
my $ExpectedRedirect = "192.168.0.1";
my $mailto = "admin\@mydomain.net";
my $ip = 'ip route flush cache';
open( INPING, "ping -c 4 $PingHost|" ) || die "ping open failed";
while( my $line =
next unless( $line =~ /Redirect Host\(New nexthop: (.*)\)/ );
next if( $1 eq $ExpectedRedirect );
open( OUTMAIL, "| mailx -s 'CH Branch VPN Unexpected Redirect: $1' $mailto" ) || die "pipe to mail failed";
print OUTMAIL scalar localtime();
print OUTMAIL "\n\n";
print OUTMAIL "Received an unexpected redirect \n";
print OUTMAIL "\n";
print OUTMAIL "have a nice day\n";
}
close(INPING) || warn "bad pipe close";
exit;
knows someone what's wrong and howto solve this problem ?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-10-2006 03:22 AM
11-10-2006 03:22 AM
Re: perl script won't send any mails
First, look at '/var/adm/syslog/mail.log' for clues.
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-10-2006 03:26 AM
11-10-2006 03:26 AM
Re: perl script won't send any mails
As pointed out by JR check the mail log first.
Also Check if u r not tring to send mail behind a firewall.
Thanks,
Siva
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-10-2006 04:29 AM
11-10-2006 04:29 AM
Re: perl script won't send any mails
test mail from the Konsole using:
echo "Message" | mailx -s "just a test" admin@mydomain.net
works without any problems.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-10-2006 05:22 AM
11-10-2006 05:22 AM
Re: perl script won't send any mails
If you are running this on HP-UX your 'ping' syntax is wrong. What you show works for AIX.
If this is HP-UX, change:
# ping -c 4 $PingHost
...to:
# ping $PingHost -n 4
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-10-2006 05:38 AM
11-10-2006 05:38 AM
SolutionIt is portable!
Some other remarks.
* -w and use warnings is double (though still better than none)
* the success or failure of ping is no guarantee at all about availability of a (mail)host
--8<---
#!/usr/bin/perl -w
use strict;
use warnings;
use Mail::Sendmail;
sendmail ({
To => "admin\@mydomain.net",
From => "me\@here.com",
Subject => "CH Branch VPN Unexpected Redirect: $1",
Message => join "\n",
scalar localtime (),
"\n",
"Received an unexpected redirect",
"",
"have a nice day",
}) or die $Mail::Sendmail::error;