cat /dev/ttyS0 (my PBX)

cat /dev/ttyS0 (my PBX)

Post by Esteb » Mon, 30 Sep 2002 10:24:23



I've got a PBX connected to my /dev/ttyS0 at 9600. With minicom
I can see the calls that where made. I wanna use a script for
getting all that data..
i've tryed from crontab
*/5 * * * cat /dev/ttyS0 > /var/log/PBX.log
it worked, but it seems that as the cat cant find a EOF from the
filehandle
it never returns 0 and never dies (so after one hour i found like 5
thousands crond. child's)..
any idea? any help?
Thanks, Esteban.
 
 
 

cat /dev/ttyS0 (my PBX)

Post by Bill Marcu » Mon, 30 Sep 2002 10:42:09


On 28 Sep 2002 18:24:23 -0700,

Quote:> I've got a PBX connected to my /dev/ttyS0 at 9600. With minicom
> I can see the calls that where made. I wanna use a script for
> getting all that data..
> i've tryed from crontab
> */5 * * * cat /dev/ttyS0 > /var/log/PBX.log
> it worked, but it seems that as the cat cant find a EOF from the
> filehandle
> it never returns 0 and never dies (so after one hour i found like 5
> thousands crond. child's)..
> any idea? any help?
> Thanks, Esteban.

Run it from /etc/inittab instead of crontab, or write a script that  
lets you test whether the cat is already running.  Maybe something like this:

#!/bin/sh
trap 'rm /var/run/pbxlog.pid' 0
echo $$ > /var/run/pbxlog.pid
cat /dev/ttyS0 > /var/log/PBX.log

 
 
 

cat /dev/ttyS0 (my PBX)

Post by Gordon Torri » Tue, 01 Oct 2002 04:35:17



> I've got a PBX connected to my /dev/ttyS0 at 9600. With minicom
> I can see the calls that where made. I wanna use a script for
> getting all that data..
> i've tryed from crontab
> */5 * * * cat /dev/ttyS0 > /var/log/PBX.log
> it worked, but it seems that as the cat cant find a EOF from the
> filehandle
> it never returns 0 and never dies (so after one hour i found like 5
> thousands crond. child's)..
> any idea? any help?
> Thanks, Esteban.

Many years ago I did exactly this using an IBM PC and MS-Kermit.
Likely you can do this using C-Kermit and modifying the following
script:

;  RECORD.TAK  -  Records Call Detail Records from the SMDR box
;  Requires MS-Kermit version 3.12 or later
DEFINE RECORD TAKE C:\KERMIT\RECORD.TAK
SET PORT 1                   ; Set for COM1
SET SPEED 4800               ; Set speed to 4,800 bps
SET PARITY NONE
SET FLOW-CONTROL RTS/CTS
;  Switch to desired directory
CWD C:\TELCO
;  Display the received characters on the screen
SET INPUT ECHO ON

;  We use a loop here so as to open and close the session log
;  once a minute. This ensures that data is written to disk and
;  not held in a buffer and minimizes the amount of data lost in
;  the event of a power failure.
;
;  The filename in which data is recorded is of the form:
;        YYYYMMDD.cdr
;  where YYYY - the year
;          MM - the month
;          DD - the day
;  To do this requires the use of MS-Kermit 3.12 or later because
;  it is done using the \v(ndate) variable.
;
;  Because the filename is the numeric date and the file is
;  opened and closed every minute, Kermit will start recording in
;  a new file every day. Be sure the clock on the PC is set to
;  the correct time-of-day!

:WAIT_LOOP
;  Close the session log file. This causes Kermit to write any
;  data in its buffers to disk first.
CLOSE SESSION
;  Re-open the session log file.
LOG SESSION \v(ndate).CDR
;  Wait 60 seconds
SET ALARM 60
PAUSE 60
;  If the script gets here before the 60 second timer expired
;  then someone pressed a key. Go to label NO_ALARM.
IF NOT ALARM GOTO NO_ALARM
INPUT 1 \255
IF FAILURE GOTO WAIT_LOOP
GOTO WAIT_LOOP

;  Someone pressed a key. Close the file and clear the screen.
:NO_ALARM
CLOSE SESSION
RUN CLS
;  I recommend good physical security for the PC running this
;  script to prevent idle people from poking it to see what it is
;  doing. Even a lockable keyboard makes a big difference.
;  I don't have physical security so I inserted the following
;  code to try and prevent repeat occurances.
;
;  After 120 times around the RPT_MSG loop (120 x 5 = 10 minutes)
;  we will go back to the WAIT_LOOP if no further key presses
;  occur.
SET COUNT 120

:RPT_MSG
;  Sound audible alarm and display a fake trouble report
;  to discourage unauthorized key-pressing in the future.
RUN WARBLE
ECHO ERROR: PBX error. PBX may not process any further calls.
ECHO        Call Mitel Repair service.
ECHO .
; Repeat every five seconds.
SET ALARM 5
PAUSE 5
IF NOT ALARM GOTO REAL_QUIT
IF COUNT GOTO RPT_MSG
GOTO WAIT_LOOP

;  Someone pressed a key while we were in the RPT_MSG loop.
;  Display another fake trouble report and then quit.
:REAL_QUIT
ECHO PBX FATAL ERROR!
ECHO All calls in progress disconnected.
STOP

-----= Posted via Newsfeeds.Com, Uncensored Usenet News =-----
http://www.newsfeeds.com - The #1 Newsgroup Service in the World!
-----==  Over 80,000 Newsgroups - 16 Different Servers! =-----

 
 
 

cat /dev/ttyS0 (my PBX)

Post by Bruce Burhan » Tue, 01 Oct 2002 07:25:33



Quote:> I've got a PBX connected to my /dev/ttyS0 at 9600. With minicom
> I can see the calls that where made. I wanna use a script for
> getting all that data..
> i've tryed from crontab
> */5 * * * cat /dev/ttyS0 > /var/log/PBX.log
> it worked, but it seems that as the cat cant find a EOF from the
> filehandle
> it never returns 0 and never dies (so after one hour i found like 5
> thousands crond. child's)..
> any idea? any help?
> Thanks, Esteban.

    What you are dealing with is a virtual file, as
in /proc....
    Take a look at man  syslogd and man syslog.conf   and maybe you can
have the
same daemon  log from ttySO  to /var/logPBXlog

HTH

Bruce<+>

 
 
 

cat /dev/ttyS0 (my PBX)

Post by Lew Pitche » Tue, 01 Oct 2002 06:01:28



> I've got a PBX connected to my /dev/ttyS0 at 9600. With minicom
> I can see the calls that where made. I wanna use a script for
> getting all that data..
> i've tryed from crontab
> */5 * * * cat /dev/ttyS0 > /var/log/PBX.log
> it worked, but it seems that as the cat cant find a EOF from the
> filehandle

Likely because your /dev/ttyS0 is running in "cooked" or "cbreak" mode,
and the data source hasn't fed a ^D (or whatever 'stty eof' is set to)
to the serial line.

You might try
a) switching to raw mode prior to the 'cat' command, or
b) switching the /dev/ttyS0 'stty eof' character to the appropriate
    character for your serial feed.

Quote:> it never returns 0 and never dies (so after one hour i found like 5
> thousands crond. child's)..
> any idea? any help?

You might also think of using 'dd' or 'tail' instead of 'cat'

--
Lew Pitcher

Master Codewright and JOAT-in-training
Registered (Slackware) Linux User #112576 (http://counter.li.org/)
begin 112576

 
 
 

1. /dev/ttys0 or /dev/ttyS0?

I have been rather confused after reading the documentation and the FAQ
(March 1993) for Linux. Some places the first serial port is referred to as
/dev/ttys0 and some places it is referred to as /dev/ttyS0. Are these just
typos and if so which one is correct???. In my /dev directory I have ttys0,
ttys1 etc. Did the device names change between releases?? I have the .99p4
release ( I know the current release is patchlevel 8, but I cannot afford the
time to reinstall Linux every three weeks when a new patchlevel is introduced!

2. KDE Control in QT Designer - How?

3. Solaris 8 box: cat file | rsh solaris_2.6_box "cat > /dev/null" SLOW

4. printing to samba printer

5. /dev/cua0 vs. /dev/ttyS0

6. Q: How to dial to an ISP on demand ?

7. Unable to bind to /dev/cua0 or /dev/ttyS0

8. Eifel patch for 4.5

9. Difference between /dev/ttyS0 and /dev/cua0

10. cat file > /dev/cua1 vs. cp file /dev/cual ?

11. cp /dev/null or cat /dev/null

12. cat /dev/mouse > /dev/audio... Newbie Help

13. cat /dev/null > /dev/rmt0 dangerous?