How to logically negate the return value of a command?

Chris Green cl at isbd.net
Wed Sep 24 15:31:00 UTC 2014


On Tue, Sep 23, 2014 at 08:46:53AM -0700, Kevin O'Gorman wrote:
>    or
>    if ping -c1 hostname ; then false; else true; fi
> 
>    You may or may not want to redirect the output of ping to /dev/null
> 
This results in the following error when ssh is run:-

    chris at x201$ ssh chris
    /bin/bash: -c: line 0: syntax error near unexpected token `then'
    /bin/bash: -c: line 0: `exec ping -c1 chris;then false; else true; fi'

The actual lines in the config file are:-

    Match host chris exec "ping -c1 chris;then false; else true; fi"
        ProxyCommand ssh cheddar nc -q0 zbmc.eu 22  


-- 
Chris Green




More information about the ubuntu-users mailing list