[Gllug] Automatic shutdown script

Andrew Halliwell ah at gnd.com
Wed Jun 11 14:15:58 UTC 2003


And verily, didst Dylan announce to the hordes:
> How should I discover the hosts to ping? The server's /etc/hosts file is kept 
> current (for sharing over NIS) so I figure that's the best place to get the 
> info. I can easily define a numerical IP range to cover the hosts in the 
> script (any one between 192.168.0.2 and 192.168.0.200 inclusive) or add 
> comments to the hosts file to tell the script what to do. Or maybe I could 
> create a set of aliases (say pingtest1, pingtest2) which the script could 
> then just use somehow.

Well, you could always do a broadcast ping and parse the output.
each one returns its ip address. So ping -b 192.168.0.255 should have a ping
reply from all active machines on the local network...

but I've noticed one thing about this, and that is that some machines won't
respond to broadcast pings. (at least by default). It might be something to
look into though.


 
> I figure recording the result of the ping test can be stored in a variable - 
> but I'm not clear on the difference between 'shell variable' and 'local 
> variable'.

There is no technical difference. The only diff between a local and an
exported one is a local is only available to the shell script that called
it, and an exported one is available to all children of the shell.
 
> Recording the final state (i.e. whether the run resulted in no response or 
> not) needs to persist from one run to the next, so is that best recorded in a 
> state file or as an environment variable?

State file, I'd say. Put it in /var/ somewhere.

-- 
Gllug mailing list  -  Gllug at linux.co.uk
http://list.ftech.net/mailman/listinfo/gllug




More information about the GLLUG mailing list