Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

read serial and split text

Status
Not open for further replies.

Sopapa

ISP
Jan 3, 2003
3
AR
Hi i have acutally this script (see below) and works fine to read the com2 of my linux box (i read news that someone send me to that port) but the problem is :

i received a notice and after the notice i receive a character (let say Y) that say me... ok this is the end of the notice, and i need split the log by notice.

Sorry for my poor english


#!/usr/bin/perl

use Device::SerialPort 0.12;

$LOGDIR = "/var/log"; # path to data file
$LOGFILE = "router.log"; # file name to output to
$PORT = "/dev/ttyS2"; # port to watch

$ob->baudrate(2600) || die "failed setting baudrate";
$ob->parity("none") || die "failed setting parity";
$ob->databits(8) || die "failed setting databits";
$ob->handshake("none") || die "failed setting handshake";
$ob->write_settings || die "no settings";

open(LOG,">>${LOGDIR}/${LOGFILE}")
||die "can't open smdr file $LOGDIR/$LOGFILE for append: $SUB $!\n";

open(DEV, &quot;<$PORT&quot;)
|| die &quot;Cannot open $PORT: $_&quot;;

select(LOG), $| = 1; # set nonbufferd mode

# Loop forver, logging data to the log file

while($_ = <DEV>){ # print input device to file
print LOG $_;
}

undef $ob;
 
Hi Sopapa,

Sorry -- could you ask your question a different way please?

If you're having trouble with English, try telling us by example. Show us the data that comes into your program and the output you would like. Mike

Want to get great answers to your Tek-Tips questions? Have a look at faq219-2884

It's like this; even samurai have teddy bears, and even teddy bears get drunk.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top