Carlos, On Tuesday 22 February 2005 12:25, Carlos E. R. wrote:
The Tuesday 2005-02-22 at 07:01 -0800, Randall R Schulz wrote:
Hi, Carlos,
It seems you have some time on your hands...
I had a free hour, and wanted to exercise my neurones :-)
When the connection goes up, /etc/ppp/poll.tcpip does this:
while true ; do set -- $(/sbin/runlevel) test -e /etc/init.d/rc${2}.d/S*xntpd && break test -x /usr/sbin/ntpdate || break checkproc /usr/sbin/xntpd &> /dev/null && break /usr/sbin/rcxntpd ntptimeset break done
It seems to me there's nothing to keep this loop from saturating the CPU if none of the conditions that allow it to terminate are met. Perhaps a "sleep" following the invocation of rcxntpd?
Well, for one, it is written by SuSE, so I shouldn't worry too much ;-) For another, I have it dissabled completely, I use my own ip-up.local instead.
Wouldn't the last line (break) break in any case?
I think it is not really a loop, only a "cute" way of chaining if/then/else sentences.
Yes, you're right, of course. Too cute by half, I'd say, but I suppose that's just because it fooled me.
Let me see... the "set" line I don't understand, but the runlevel comand "prints the previous and current system runlevel on its standard output, separated by a single space. If there is no previous system runlevel, the letter N will be printed instead". Ah, it sets the first parameter to "N" and the second ${2} to "5" in my system.
Set does dual duty. It can change shell options and it can set the positional parameters. It's the latter use being made in this case. The previous and current run levels become $1 and $2, as you note.
...
This brings up another thing I just learned recently:
...
Pause for NUMBER seconds. SUFFIX may be 's' for seconds (the default), 'm' for minutes, 'h' for hours or 'd' for days. Unlike most implementations that require NUMBER be an integer, here NUMBER may be an arbitrary floating point number.
Note in particular the last sentence.
Yes, I use it fairly often. I didn't remember about the floating point, though. Funny, and interesting :-)
I'm not laughing. But I've found it to be handy.
Carlos Robinson
Randall Schulz