Sponsored Content
Top Forums Programming Ping test sends mail when ping fails Post 302986315 by RudiC on Wednesday 23rd of November 2016 12:45:12 PM
Old 11-23-2016
The return code of your function is the wrong way: 0 indicates success; 1 (better: anything but 0) indicates error.
And, there's a then missing for the if construct.
And, there might be a logic error: the for loop would work on a list of hosts and return success if any of them would ping.
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

PERL: ping and e-mail

I need a script to open a text file with ip's in it, ping them, split the results into the ip and time from the results and e-mail them ? here what i've done. its porbly wrong and not workin.its for win nt4 use Net::SMTP; # get list of ip's to ping open (PINGFILE, "< c:\\Documents and... (20 Replies)
Discussion started by: perleo
20 Replies

2. UNIX for Dummies Questions & Answers

Cron Sends mail to root on completion of job.

All I am running a few scripts through a cron job. This is for checking some key services that are running on by box. The problem is, everytime the cron runs, it sends a mail to the root account. The root account mails need to cleared every now and then. Is there some way I can stop these... (1 Reply)
Discussion started by: skotapal
1 Replies

3. Shell Programming and Scripting

help: infinant loop script - host ping test

need to check on some hosts and send an email if there status changes I wanna put together a script in bash that will allow me to check the up/down state of a single host via ping i want it to run in a continuous loop so I can just fire the script and forget about it(dont want cron to drive... (2 Replies)
Discussion started by: zeekblack
2 Replies

4. Shell Programming and Scripting

PHP Script that sends mail - Postfix breaks it

I have a PHP Script that works perfectly on a server that uses Sendmail. However I tried to port it to a new server that has the Postfix to Sendmail compatibility interface, and it doesn't work properly. The php.ini file has the path for sendmail on both servers set to: /usr/sbin/sendmail -t... (0 Replies)
Discussion started by: boopfm523
0 Replies

5. Shell Programming and Scripting

Running script that sends an html formatted email fails when its run as cronjob

Hi Im very new at working with unix and this problem I simply can not understand. I know there are a lot of threads about problems with shell scripts behaving differently when run from a terminal and from a cronjob. I have tried everything(almost) but I still havent cracked this problem. Im... (15 Replies)
Discussion started by: Nightowl
15 Replies

6. Shell Programming and Scripting

how to know if the mailx command really sends the mail to the email address?

Hi guys, I have a question about the returning message of the mailx command. if I run a mailx command, how can I know if the email has been sent to the email address? If the email address doesn't exist, is there any error message returned? If yes, how can I get the error message? Thanks... (3 Replies)
Discussion started by: sheenshine
3 Replies

7. Shell Programming and Scripting

Animation Ping on Solaris Like Cisco Ping

Hi, I develop simple animation ping script on Solaris Platform. It is like Cisco ping. Examples and source code are below. bash-3.00$ gokcell 152.155.180.8 30 Sending 30 Ping Packets to 152.155.180.8 !!!!!!!!!!!!!.!!!!!!!!!!!!!!!. % 93.33 success... % 6.66 packet loss...... (1 Reply)
Discussion started by: gokcell
1 Replies

8. Shell Programming and Scripting

How to get reason for ping failure using perls Net::Ping->new("icmp");?

Hi I am using perl to ping a list of nodes - with script below : $p = Net::Ping->new("icmp"); if ($p->ping($host,1)){ print "$host is alive.\n"; } else { print "$host is unreacheable.\n"; } $p->close();... (4 Replies)
Discussion started by: tavanagh
4 Replies

9. Homework & Coursework Questions

Creating a function that sends a mail using mail command

Use and complete the template provided. The entire template must be completed. If you don't, your post may be deleted! 1. The problem statement, all variables and given/known data: The function will be called m and it will allow you to send an email to someone using the mail command. The... (1 Reply)
Discussion started by: Drucian
1 Replies

10. Shell Programming and Scripting

Ping test using python

I am issuing a reboot command to a client server from admin server using my python function. I am able to do that but now I need do a ping test every second and print if the ping is successful. With the below code I can check ping only once. import os hostname = "myclient" response =... (7 Replies)
Discussion started by: ctrld
7 Replies
AnyEvent::XMPP::Ext::Ping(3pm)				User Contributed Perl Documentation			    AnyEvent::XMPP::Ext::Ping(3pm)

NAME
AnyEvent::XMPP::Ext::Ping - Implementation of XMPP Ping XEP-0199 SYNOPSIS
use AnyEvent::XMPP::Ext::Ping; my $con = AnyEvent::XMPP::IM::Connection->new (...); $con->add_extension (my $ping = AnyEvent::XMPP::Ext::Ping->new); # this enables auto-timeout of a connection if it didn't answer # within 120 seconds to a ping with a reply $ping->enable_timeout ($con, 120); my $cl = AnyEvent::XMPP::Client->new (...); $cl->add_extension (my $ping = AnyEvent::XMPP::Ext::Ping->new); # this enables auto-timeout of newly created connections $ping->auto_timeout(120); $ping->ping ($con, 'ping_dest@server.tld', sub { my ($time, $error) = @_; if ($error) { # we got an error } # $time is a float (seconds) of the rtt if you got Time::HiRes }); DESCRIPTION
This extension implements XEP-0199: XMPP Ping. It allows you to define a automatic ping timeouter that will disconnect dead connections (which didn't reply to a ping after N seconds). See also the documentation of the "enable_timeout" method below. It also allows you to send pings to any XMPP entity you like and will measure the time it took if you got Time::HiRes. METHODS
new (%args) Creates a new ping handle. auto_timeout ($timeout) This method enables automatic connection timeout of new connections. It calls "enable_timeout" (see below) for every new connection that was connected and emitted a "stream_ready" event. This is useful if you want connections that have this extension automatically timeouted. In particular this is useful with modules like AnyEvent::XMPP::Client (see also SYNOPSIS above). enable_timeout ($con, $timeout) This enables a periodical ping on the connection $con. $timeout must be the seconds that the ping intervals last. If the server which is connected via $con didn't respond within $timeout seconds the connection $con will be disconnected. Please note that there already is a basic timeout mechanism for dead TCP connections in AnyEvent::XMPP::Connection, see also the "whitespace_ping_interval" configuration variable for a connection there. It then will depend on TCP timeouts to disconnect the connection. Use "enable_timeout" and "auto_timeout" only if you really feel like you need an explicit timeout for your connections. ping ($con, $dest, $cb, $timeout) This method sends a ping request to $dest via the AnyEvent::XMPP::Connection in $con. If $dest is undefined the ping will be sent to the connected server. $cb will be called when either the ping timeouts, an error occurs or the ping result was received. $timeout is an optional timeout for the ping request, if $timeout is not given the default IQ timeout for the connection is the relevant timeout. The first argument to $cb will be the seconds of the round trip time for that request (If you have Time::HiRes). If you don't have Time::HiRes installed the first argument will be undef. The second argument to $cb will be either undef if no error occured or a AnyEvent::XMPP::Error::IQ error object. ignore_pings ($bool) This method is mostly for testing, it tells this extension to ignore all ping requests and will prevent any response from being sent. AUTHOR
Robin Redeker, "<elmex at ta-sa.org>", JID: "<elmex at jabber.org>" COPYRIGHT &; LICENSE Copyright 2007, 2008 Robin Redeker, all rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. perl v5.14.2 2012-01-23 AnyEvent::XMPP::Ext::Ping(3pm)
All times are GMT -4. The time now is 07:38 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy