Re: [SLUG] Capturing /dev/tty1A informaiont (help Ian)

From: Brad Smith (brad_stephenssmith@yahoo.com)
Date: Sat Jun 07 2003 - 11:40:36 EDT


I imagine you could do something similar with bash (store the output to a variable, I guess) but I
wouldn't have the first clue how to do that. Or heck, the program would probably be simple enough
to write in C and then not worry (so much) about portability at all.

By the way, I wrote that last suggestion right after I'd woken up and I realize now that buffering
the data is unnescesary and maybe problematic. There's no reason I can see not to just read a
line, write a line, repeat. TI'm also thinking that there's also really no need to get anything
fancy from CPAN if you've already got tools that will dump out the nescesary data. Try this and
see if it works:

-----------------------------------------
#!/usr/bin/perl

$filename = $ARGV[0] ? $ARGV[0] : "log.txt";
$timestamp = localtime(time());

open(OUTFILE, ">>$filename") or die("Could not open file: $filename -- $!\n");
open(PDATA, "tail -f /dev/tty1a |tee |") or die ("Could not run command! -- $!\n");

print (OUTFILE "\n$timestamp\n---------------------------------------------\n");
while (<PDATA>)
{
        print(OUTFILE "$_\n");
}

close(OUTFILE);
-----------------------------------------

Good luck! =:)

--- Mike Manchester <mchester@pobox.com> wrote:
> Thanks Brad, I'll look into that. I'm not sure all clients have Perl
> installed on the servers as some of the these servers are old.
>
> Mike M.
> I'm off to check CPAN :)
>
> On Sat, 2003-06-07 at 07:17, Brad Smith wrote:
> > Maybe the solution could be as simple as a perl script that buffers the data and then does a
> > propper open/write/close on the file? Should be easy enough to do.
> >
> > --Brad
> >
> >
> > --- Mike Manchester <mchester@pobox.com> wrote:
> > > Here's the scoop.
> > > At work we have a software program (tinyterm) that dials into a remote
> > > site and sends and receives mostly ascii data. What we would like to do
> > > is echo the traffic through the tty1A (or what ever port the modem is
> > > on) to a file. In hopes of this will help troubleshoot connections
> > > problems. It would be nice if there was a standard unix way of doing
> > > this as we really don't want to install software on a customers site if
> > > it can be helped. Is it possible to do something like this using tee and
> > > maybe tail -f. We played around with using tail -f /dev/tty1a |tee
> > > temp.log but we had no way to close the file thus the data was always
> > > lost.
> > >
> > > Any help / suggestions would be appricated.
> > >
> > > Mike M.



This archive was generated by hypermail 2.1.3 : Fri Aug 01 2014 - 16:21:18 EDT