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

Holger Macht hmacht at suse.de
Tue Aug 14 07:55:36 PDT 2007


On Tue 14. Aug - 07:01:14, Dan Nicholson wrote:
> 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.

Oh well, this script magic ;-)

I'll reconsider the awk usage..., thanks for your suggestions.

> Looks very cool, though.

Thanks,
	Holger


More information about the hal mailing list