Kris Kerwin wrote:
Thanks Jonathan.
Anyone have any thoughts on this? I'm not a bash or any other programmer, and
was wondering if this would work. And how might I code that while loop?
Actually - the while loop was fine. I wrote that line and thought I can't
do that! I'll have to look it up before I send it out - it was originally
white (1) - but in doing so, I forgot to delete the statement.
while true; do
if [ -e /tmp/stopdmesg ]; then
exit;
else
dmesg > dmesg-$(date +%Y%m%d%H%M%S)
sleep(5)
fi
done
In theory, the following code should do it:
--cut-------------------
#!/bin/bash
if [ -z $1 ]; then
echo "sleep time not given"
exit
fi
while true; do
if [ -e /tmp/stopdmesg ]; then
exit;
else
dmesg > /tmp/dmesg-$(date +%Y%m%d%H%M%S)
echo -n "."
sleep $1
fi
done
--cut-------------------
You can then run to program (say it's in a file called dcat)
$ ./dcat 5
which will sleep for 5 seconds at a time, before outputting the dmesg
contents to /tmp/dmesg-(time), (e.g. /tmp/dmesg-20050917231913)
For each output, you'll see a period on screen, e.g.
$ ./dcat 5
..................................
So you can track. But you can delete the 'echo -n "."' line if you want to
stop that. Finally, to stop it, you can either kill the process, or create
an empty file called stopdmesg in /tmp:
$ touch /tmp/stopdmesg
which will terminate the loop and the program.
Hope that all helps and gets you the information your after!
--
Jonathan Wright ~ mail at djnauk.co.uk
~ www.djnauk.co.uk
--
2.6.12-gentoo-r6-djnauk-b2 AMD Athlon(tm) XP 2100+
up 1 day, 12:08, 4 users, load average: 4.58, 2.76, 2.62
--
"Labels can also be misleading. I saw a news report about a
lesbian protest march, and the reporter said, 'Coming up next, a
lesbian demonstration.' My first thought was, 'Cool. I always
wondered how those things work.'"
~ Michael Dane, Comedian
--
[email protected] mailing list