Hi,<br><br>From my file server I want to start the backup server by WOL, run the backup and then power it down.<br><br>I found the script below on the web and it works.&nbsp; However it comes with the warning &quot;Be careful, you could corrupt valid entries if those NICs are already active&quot;.&nbsp; Does anyone have a better magic packet creating script which is fail safe?
<br><br>The next problem is powering down.&nbsp; When I run halt (slackware) the power is left on and the last line of output says Power Down.&nbsp; I need it to actually power down.&nbsp; The machine I am testing on is a Pentium II with an ATX power supply, so I assume it is capable of switching itself off.&nbsp; I tried halt -p but that made not difference.&nbsp; Any suggestions?&nbsp; I also tried apm -S and got the message &quot;No apm support in the kernel&quot;, do I really need apm support in the kernel?
<br><br>#!/usr/bin/perl -w<br>#<br># Reads from stdin or a file lines of the form<br>#<br># <a href="http://12.34.56.78">12.34.56.78</a> aa:bb:cc:dd:ee;ff or<br># <a href="http://foo.bar.com">foo.bar.com</a> aa:bb:cc:dd:ee:ff
<br>#<br># which are hostname and MAC addresses of NICs to send a wakeup packet.<br>#<br># This program may have to be run with superuser privilege because it<br># may need to inject an ARP entry into the cache.<br># Be careful, you could corrupt valid entries if those NICs are
<br># already active.<br>#<br># Perl version by <a href="mailto:ken.yap@acm.org">ken.yap@acm.org</a> after DOS/Windows C version posted by<br># <a href="mailto:Steve_Marfisi@3com.com">Steve_Marfisi@3com.com</a> on the Netboot mailing list
<br># Released under GNU Public License, 2000-01-05<br>#<br>use Socket;<br><br>while (&lt;&gt;) {<br>&nbsp;&nbsp;&nbsp; ($ip, $mac) = split;<br>&nbsp;&nbsp;&nbsp; next if !defined($ip) or !defined($mac) or $ip eq '' or $mac eq '';<br>&nbsp;&nbsp;&nbsp; &amp;send_wakeup_packet($ip, $mac);
<br>}<br><br>sub send_wakeup_packet {<br>&nbsp;&nbsp;&nbsp; ($ip, $mac) = @_;<br><br>&nbsp;&nbsp;&nbsp; if (!defined($iaddr = inet_aton($ip))) {<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; print &quot;Cannot resolve $ip\n&quot;;<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; return;<br>&nbsp;&nbsp;&nbsp; }<br>&nbsp;&nbsp;&nbsp; if ($mac !~ /[\da-f]{2}:[\da-f]{2}:[\da-f]{2}:[\da-f]{2}:[\da-f]{2}:[\da-f]{2}/i)&nbsp; {
<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; print &quot;Malformed MAC address $mac\n&quot;;<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; return;<br>&nbsp;&nbsp;&nbsp; }<br>&nbsp;&nbsp;&nbsp; # Inject entry into ARP table, in case it's not there already<br>&nbsp;&nbsp;&nbsp; system(&quot;arp -s $ip $mac&quot;) == 0<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; or print &quot;Warning: arp command failed, you need to be root\n&quot;;
<br>&nbsp;&nbsp;&nbsp; # Remove colons<br>&nbsp;&nbsp;&nbsp; $mac =~ tr/://d;<br>&nbsp;&nbsp;&nbsp; # Magic packet is 6 bytes of FF followed by the MAC address 16 times<br>&nbsp;&nbsp;&nbsp; $magic = (&quot;\xff&quot; x 6) . (pack('H12', $mac) x 16);<br>&nbsp;&nbsp;&nbsp; # Create socket<br>&nbsp;&nbsp;&nbsp; socket(S, PF_INET, SOCK_DGRAM, getprotobyname('udp'))
<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; or die &quot;socket $!\n&quot;;<br>&nbsp;&nbsp;&nbsp; # Send the wakeup packet<br>&nbsp;&nbsp;&nbsp; print &quot;Sending wakeup packet to $ip at MAC address $mac\n&quot;;<br>&nbsp;&nbsp;&nbsp; defined(send(S, $magic, 0, sockaddr_in(0x2fff, $iaddr)))<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; or print &quot;send: $!\n&quot;;
<br>&nbsp;&nbsp;&nbsp; close(S);<br>}<br><br>Perhaps we can have an evening devoted to power saving and IT environmental issues?<br><br>Thanks,<br>Ashley<br><br>