[Gllug] Automatic shutdown script

Dylan dylan at dylan.me.uk
Mon Sep 8 18:08:34 UTC 2003


On Wednesday 11 June 2003 15:15, Andrew Halliwell wrote:
> 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...

I'll look at this - I'd still not know what command to use to filter and parse 
the output though...

>
> 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.

Doesn't look like that's a problem here, they all responded when I tried it.

>
> > 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.

Ah, so a shell variable is an exported variable, ic now.

>
> > 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.

I was planning /var/tmp

Cheers

Dylan

-- 
Sweet moderation
Heart of this nation
Desert us not
We are between the wars
- Billy Bragg

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




More information about the GLLUG mailing list