[CLUE-Tech] Wakeon LAN shell script

Kevin Cullis kevincu at orci.com
Mon Feb 25 13:14:49 MST 2002


Dave,

Will's comments:

> That's absolutely correct...
> You need to either use telnet >> or netcat to actually send the packet.
> It was just to represent how you FORM the magic packet, that's the real
> magic and exercise.
> Of course OpenBSD has netcat installed as default... :)

Kevin

Dave Anselmi wrote:
> 
> Not to complain, but the script looks incomplete.  It builds the wake
> string but never sends it.  I assume it uses something like ncat for that.
> 
> Dave
> 
> Kevin Cullis wrote:
> 
> > Hi all,
> >
> > Will Stevenson, from OMI, talked about this wakeon LAN shell script
> > during the installfest and he passed it on to me to give to you all.
> > Here it is:
> >
> > -----------
> >
> > #! /bin/sh
> >
> > # Usage: wake <host> [<MAC address>]
> > #
> > # <host> can be a host name or a dotted-quad IP address.
> > # If the <MAC address> is not given, it is taken from ethers(5).
> > # For this to work, if you give a host name as first argument, ethers
> > # has to contain host names (as opposed to IP addresses).
> > #
> > # Unless you have it already, you can build your ethers file like this:
> > #
> > # nmap -sP -PI 192.168.1.0/24   # prepare ARP cache with a ping-sweep
> > # arp -a | awk '$5 == "[ether]" { printf("%s\t%s\n", $4, $1); }' \
> > #        | sort >>/etc/ethers
> > #
> > # The 'magic packet' consists of 6 times 0xFF followed by 16 times
> > # the hardware address of the NIC. This sequence can be encapsulated
> > # in any kind of packet; I chose UDP to the discard port (9).
> >
> > if [ $# = 1 ]; then
> >   ETHER=`awk "/$1/"' { gsub(":", "", $1); print $1; exit; }'
> > /etc/ethers`
> >   if [ -z $ETHER ]; then
> >     echo "$0: host $1 is not in /etc/ethers" >&2
> >     exit 1
> >   fi
> > else
> >   ETHER=$2
> > fi
> >
> > ETHER="${ETHER}${ETHER}${ETHER}${ETHER}"                # 4 x MAC
> > ETHER="FFFFFFFFFFFF${ETHER}${ETHER}${ETHER}${ETHER}"    # Preamble + 16
> > x MAC
> >
> > -----------
> >
> > I'm not a script writer yet, so most of you should understand it.  If
> > not, ask away and I'll forward your comments to him.
> >
> > Kevin
> > _______________________________________________
> > CLUE-Tech mailing list
> > CLUE-Tech at clue.denver.co.us
> > http://clue.denver.co.us/mailman/listinfo/clue-tech
> 
> _______________________________________________
> CLUE-Tech mailing list
> CLUE-Tech at clue.denver.co.us
> http://clue.denver.co.us/mailman/listinfo/clue-tech

-- 

"Success is never final, failure is never fatal" - Kevin Cullis
---
Kevin Cullis
kcullis at coloradoexcellence.org
303-893-CPEX (2739)
Colorado Performance Excellence, Inc
http://www.coloradoexcellence.org



More information about the clue-tech mailing list