How to logically negate the return value of a command?

Chris Green cl at isbd.net
Wed Sep 24 15:37:07 UTC 2014


On Wed, Sep 24, 2014 at 04:31:00PM +0100, Chris Green wrote:
> 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  
> 
That is of course:-

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

... but the error is exactly the same.

-- 
Chris Green




More information about the ubuntu-users mailing list