Using a commands return value in bash

Caporegime
Joined
18 Oct 2002
Posts
29,493
Location
Back in East London
Hi all,

I'm knocking up a script which is used to determine if the box has a lan connection or not.. I was hoping to use:
Code:
#!/bin/bash
if [ `/etc/init.d/net.eth0 --quiet status` ]
then
  echo This machine has a LAN connection
else
  echo This machine does not have a LAN connection
fi
The /etc/init.d/net.eth0 --quiet status command returns true/false, but as I understand it, bash is a bit funny about booleans?

Any pointers? Ta.
 
Last edited:
Nevermind, found the solution:

Code:
#!/bin/bash

if [ -f /etc/init.d/net.eth0 ] && `/etc/init.d/net.eth0 --quiet status`
then
        echo The service is present and started!
else
        echo The service is not present, or has not been started!
fi
 
Back
Top Bottom