How to logically negate the return value of a command?

Chris Green cl at isbd.net
Tue Sep 23 18:26:35 UTC 2014


On Tue, Sep 23, 2014 at 11:34:41AM -0400, Nathan Dorfman wrote:
> On Mon, Sep 22, 2014 at 2:04 PM, Chris Green <cl at isbd.net> wrote:
> > However this doesn't work of course.  Is there any easy way (i.e. an
> > executable command) which will logically not the value that ping
> > returns?  I know I could write a little script that does the job but
> > if can do it without I'd be happier.
> 
> 
> There's probably a nicer way to do it, but this should work:
> 
>     ping -c1 hostname; test "$?" -ne 0
> 
That won't work in this case because there's no shell running when the
program is exec'ed from the ssh config file. 

-- 
Chris Green




More information about the ubuntu-users mailing list