Utilities which go into the install media should not be grown without
cause, or at the very least, growth wrapped with #ifndef SMALL.
I think if you want some messages quieted, maybe you should look up
some standard unix utilities.
ping host 2>&1 | awk '/is down/{next}{print}'
Penned by Vadim Zhukov on 20110512 17:54.19, we have:
| Hello all.
|
| Following diff adds new option to ping(8), making it not output
| messages "host is down" and "network is down". Very useful when you're
| monitoring/fixing routing problems, with ping started in one window, and
| you already know that no packets mean problems, and error messages just
| spam your window. Works for me for a long time.
|
| Mnemonic for -W is "Wait until this shit comes up". :)
|
| If this goes in, I'll do the same for ping6(8).
|
| --
| Best wishes,
| Vadim Zhukov
|
| A: Because it messes up the order in which people normally read text.
| Q: Why is top-posting such a bad thing?
| A: Top-posting.
| Q: What is the most annoying thing in e-mail?
|
|
| Index: ping.8
| ===================================================================
| RCS file: /cvs/src/sbin/ping/ping.8,v
| retrieving revision 1.45
| diff -u -p -r1.45 ping.8
| --- ping.8 3 Jul 2010 04:44:51 -0000 1.45
| +++ ping.8 12 May 2011 22:46:41 -0000
| @@ -39,7 +39,7 @@
| .Sh SYNOPSIS
| .Nm ping
| .Bk -words
| -.Op Fl DdEefLnqRrv
| +.Op Fl DdEefLnqRrvW
| .Op Fl c Ar count
| .Op Fl I Ar ifaddr
| .Op Fl i Ar wait
| @@ -192,6 +192,13 @@ Verbose output.
| ICMP packets other than
| .Dv ECHO_REPLY
| that are received are listed.
| +.It Fl W
| +Do not print
| +.Dq Host is down
| +or
| +.Dq Network is down
| +error messages.
| +Mnemonic: Wait until it come up.
| .It Fl w Ar maxwait
| Specifies the maximum number of seconds to wait for responses
| after the last request has been sent.
| Index: ping.c
| ===================================================================
| RCS file: /cvs/src/sbin/ping/ping.c,v
| retrieving revision 1.88
| diff -u -p -r1.88 ping.c
| --- ping.c 3 Jul 2010 04:44:51 -0000 1.88
| +++ ping.c 12 May 2011 22:46:41 -0000
| @@ -108,6 +108,7 @@ int options;
| #define F_SO_JUMBO 0x1000
| #define F_AUD_RECV 0x2000
| #define F_AUD_MISS 0x4000
| +#define F_NODOWN 0x8000
|
| /* multicast options */
| int moptions;
| @@ -201,7 +202,7 @@ main(int argc, char *argv[])
| preload = 0;
| datap = &outpack[8 + sizeof(struct tvi)];
| while ((ch = getopt(argc, argv,
| - "DEI:LRS:c:defi:jl:np:qrs:T:t:V:vw:")) != -1)
| + "c:DdEefI:i:jL:l:np:qRrS:s:T:t:V:vWw:")) != -1)
| switch(ch) {
| case 'c':
| npackets = (unsigned long)strtonum(optarg, 0,
| @@ -319,6 +320,9 @@ main(int argc, char *argv[])
| case 'v':
| options |= F_VERBOSE;
| break;
| + case 'W':
| + options |= F_NODOWN;
| + break;
| case 'w':
| maxwait = (unsigned int)strtonum(optarg, 1, INT_MAX,
| &errstr);
| @@ -653,11 +657,15 @@ pinger(void)
| sizeof(whereto));
|
| if (i < 0 || i != cc) {
| - if (i < 0)
| - perror("ping: sendto");
| - snprintf(buf, sizeof buf, "ping: wrote %s %d chars, ret=%d\n",
| - hostname, cc, i);
| - write(STDOUT_FILENO, buf, strlen(buf));
| + if (i >= 0 || (errno != ENETDOWN && errno != EHOSTDOWN) ||
| + (options & F_NODOWN) != F_NODOWN) {
| + if (i < 0)
| + perror("ping: sendto");
| + snprintf(buf, sizeof buf,
| + "ping: wrote %s %d chars, ret=%d\n",
| + hostname, cc, i);
| + write(STDOUT_FILENO, buf, strlen(buf));
| + }
| }
| if (!(options & F_QUIET) && options & F_FLOOD)
| (void)write(STDOUT_FILENO, &DOT, 1);
| @@ -1363,7 +1371,7 @@ void
| usage(void)
| {
| (void)fprintf(stderr,
| - "usage: ping [-DdEefLnqRrv] [-c count] [-I ifaddr] [-i wait]\n"
| + "usage: ping [-DdEefLnqRrWv] [-c count] [-I ifaddr] [-i wait]\n"
| "\t[-l preload] [-p pattern] [-s packetsize] [-T tos] [-t ttl]\n"
| "\t[-V rtable] [-w maxwait] host\n");
| exit(1);
--
Todd Fries .. [email protected]
_____________________________________________
| \ 1.636.410.0632 (voice)
| Free Daemon Consulting, LLC \ 1.405.227.9094 (voice)
| http://FreeDaemonConsulting.com \ 1.866.792.3418 (FAX)
| 2525 NW Expy #525, Oklahoma City, OK 73112 \ sip:[email protected]
| "..in support of free software solutions." \ sip:[email protected]
\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
37E7 D3EB 74D0 8D66 A68D B866 0326 204E 3F42 004A
http://todd.fries.net/pgp.txt