On Tue, Mar 30, 2010 at 7:23 PM, Byron Clark <by...@theclarkfamily.name>wrote:
> On Tue, Mar 30, 2010 at 07:09:31PM -0600, Brian Phillips wrote: > > Will return "true" (execute the following code) if the ping response is > > reasonable and "false" if the ping times out. > > > > What if the count is increased? What is the behavior of the following > > command: > > > > code:===================================== > > if ping -c 2 $GATEWAY &> /dev/null > > code:===================================== > > >From ping(8): > > If ping does not receive any reply packets at all it will > exit with code 1. If a packet count and deadline are both > specified, and fewer than count packets are received by the > time the deadline has arrived, it will also exit with code 1. > On other error it exits with code 2. Otherwise it exits with > code 0. This makes it possible to use the exit code to see if > a host is alive or not. > > So, in your example, the if condition will be true if any packets arrive > and > false otherwise. > > I don't think that is what it says. If you specify count 2 and you only get 1 response, it will exit with exit code 1. If you specify 2, then it has to receive both packets for it to return exit code 0. Robert LeBlanc Life Sciences & Undergraduate Education Computer Support Brigham Young University
-------------------- BYU Unix Users Group http://uug.byu.edu/ The opinions expressed in this message are the responsibility of their author. They are not endorsed by BYU, the BYU CS Department or BYU-UUG. ___________________________________________________________________ List Info (unsubscribe here): http://uug.byu.edu/mailman/listinfo/uug-list