SUMMARY:Sol 2.3 Serial port listener

From: Tony Cormier (tony@Manic5.Hydro.Qc.CA)
Date: Wed Jan 25 1995 - 06:47:28 CST


My original posting was :
Hi gurus,
we need a program that would listen on a serial port 24 hours a days
and that would not take a lot of memory.
It must not offer any login because data come from a pc and the caracteres
received will all be transmitted to a specified file in our ipx using
an alm card and running sol 2.3.

If anybody knows how to configure such a setup or has a script wich
does that . I'd be infinitely gratefull to hear from you. Thanks

I'll summaryze.

Many thanx to the 3 person who replyed. The litle ksh script worked ok for me.
(haven't try the two others: Thankx anyway).
Here are the answers:

From: dougcarr@aen.uky.edu
 Here is a short Ksh script that I use to monitor our phone accounting
system. You should disable any getty running on the serial port that
you want to monitor.

#!/bin/ksh
FILE="/usr/adm/`date +%m%y.log`"
exec 3< /dev/ttys06
stty 2400 -parenb -parodd cs7 cstopb -ixoff igncr < /dev/ttys06

while true
  do
  cat <&3 >> $FILE
done
(END)

From: bill@tieman.inteleq.com (Bill McSephney)
Below you will find a very quick perl script I used to monitor a port
for over 3 years to wastch for infomation from a telepnone system and
work with the data. I have taken the part out that works with the data
but this should do what you are looking for.

    #!/usr/local/bin/perl
    #
    #---- Setup base ENV
    #

    $LOGDIR = "/var/spool"; # path to data file
    $LOGFILE = "data_file"; # file name to out put to
    $PORT = "/dev/ttya"; # port to watch
    $PORT_PARM = "raw 4800"; # sets the port to raw mode and 4800 baud

    #
    #---- open the logfile
    #
    open(LOG,">>${LOGDIR}/${LOGFILE}")
        ||die "can't open smdr file $LOGDIR/$LOGFILE for append: $SUB $!\n";
    select(LOG), $| = 1; # set nonbufferd mode

    #
    #---- open input file ( tty port in this case)
    #
    open(IN,"<${PORT}")
        ||die "can't open $PORT: $SUB $!\n";
    system("/usr/5bin/stty ${PORT_PARM} < ${PORT}"); # set port env
    select(IN), $| = 1; # set nonbufferd mode

    #
    #---- actual loop that reads in all the stuff and sends it out again
    #
    while(<IN>){ # print input device to file
        print LOG $_;
    }

Good luck.

From: wes@kempfer.com
Have you tried 'cat < /dev/ttyXXX > /var/spool/serial_inputXXX' ?



This archive was generated by hypermail 2.1.2 : Fri Sep 28 2001 - 23:10:14 CDT