Re: [SLUG] BASH and a comm port

From: Eben King (eben1@tampabay.rr.com)
Date: Wed Jan 25 2006 - 01:28:12 EST


On Tue, 24 Jan 2006, Ron Youvan wrote:

> My stupid LINUX books only say some special understanding (of some kind)
> is required to deal with comm. ports when using bash script files.
> (I can do anything with a few examples, but they are scarce in my books,
> I am just a user.)

What I did when writing a script to watch a modem (external), was put "chat"
in a loop, something like

while : ; do
   chat -t 9999999 -V string_in_text ""
done > logfile 2>&1

Can't tell chat to wait forever, but 9,999,999 seconds is about 19 years;
that should do.

> At 0000 hrs a new file will be created and the string will be append that
> file.

Then heck, try something like this:

trap 'cmd=break ; kill -HUP $chatpid' USR1

while : ; do
   cmd=:
   while : ; do
     chat -t 9999999 -V string_in_text "" &
     chatpid=$!
     eval $cmd
   done >> `date +%Y%m%d`
done

At midnight, have cron send it (the whole script, not chat) a SIGUSR1.
Mostly untested.

Or, always have it write to the same file, and have logrotate handle the
renaming (though I don't know if it does date naming, or just sequential
naming).

> Another related question:
> I think I want to start this program from int

What is int?

> but I don't know how to assign the tee-ed output to a virtual console #
> (unless it would default to #1) which would be fine.

How about running "tail -f" on its logfile?

> Although everything is on a UPS, if the computer does reboot I need the
> computer to resume as soon as possible.

Invoke it from rc.local then.

-- 
-eben    ebQenW1@EtaRmpTabYayU.rIr.OcoPm    home.tampabay.rr.com/hactar

Q: What kind of modem did Jimi Hendrix use? A: A purple Hayes. ----------------------------------------------------------------------- This list is provided as an unmoderated internet service by Networked Knowledge Systems (NKS). Views and opinions expressed in messages posted are those of the author and do not necessarily reflect the official policy or position of NKS or any of its employees.



This archive was generated by hypermail 2.1.3 : Fri Aug 01 2014 - 17:07:43 EDT