[PATCH 1/3] WOL: Script to check status and to enable/disable Wake On LAN

Dan Nicholson dbn.lists at gmail.com
Tue Aug 14 07:01:14 PDT 2007


On 8/14/07, Holger Macht <hmacht at suse.de> wrote:
> +
> +    SUPPORT_FLAGS=`ethtool $IFACE | grep "Supports Wake-on:" | awk '{ print $3 }' | grep g`
> +    [ -n "$SUPPORT_FLAGS" ] && return 0

This is totally minor, but if you're going to call out to a
heavyweight process like awk, you might as well make use of all its
features:

ethtool $IFACE | awk '/Supports Wake-on:/{print $3}' | grep g
or
ethtool $IFACE | awk '/Supports Wake-on:/{if ($3 ~ /g/) print $3}'

Or just using the exit status:
ethtool $IFACE | awk '/Supports Wake-on/{if ($3 ~ /g/) exit 1}'
or
ethtool $IFACE | awk '/Supports Wake-on/{exit !($3 ~ /g/)}'

> +    ENABLED=`ethtool $IFACE | grep "[^s ]Wake-on:" | awk '{ print $2 }' | grep g`

Similarly, a general `awk /regex/{commands}' would suffice.

Looks very cool, though.

--
Dan


More information about the hal mailing list