demystification of "chat" - re: /dev/tty* + modem test logic
Max Blanco
blanco-S8qYAnHmZTt34ZA5RureAJ4VBq8PJc8F at public.gmane.org
Mon Aug 25 13:55:54 UTC 2003
Thanks to Tim and Peter for their demystification of the "chat" command.
My test logic made no sense as I tried vainly to set up my modem: I had
thought "chat" looked at "/dev/modem" implicitly. Not so - see below.
A better logic (?) is at end.
Tim Writer wrote:
> Max Blanco <blanco-S8qYAnHmZTt34ZA5RureAJ4VBq8PJc8F at public.gmane.org> writes:
>
> > Through which /dev port does "chat" cmd look?
> >
> > I can't find this info anywhere in the chat man page. There exists no
> > "usr/share/doc/chat" directory.
>
> I believe it reads from standard input and writes to standard output.
> If you're using it with PPP, pppd arranges to connect its standard input
> and standard output to the relevant tty.
On Sat, 23 Aug 2003, Peter L. Peres wrote:
>
> chat talk to its stdin and stdout but it will not work stand-alone, as in:
>
> chat "" ATZ OK </dev/modem >/dev/modem
>
> because the line disipline and buffering need to be set. pppd does this
> before calling chat. calling chat as above will fail on any machine, in
> despite of working modem etc. The call will hang (can be interrupted with
> ^C).
>
I would appreciate helpful comments on this...:
---begin untested perl code: "/usr/bin/mdmtst"---
#!/usr/bin/perl
print STDOUT "mdmtst: program to test your modem.\n";
print STDOUT "\tuse at own risk\n";
#dialout string:
$mdmstrng="ATL1DT4165551212\n";
print STDOUT "\tusing: $mdmstrng\n";
#dmesg check:
$dmesg=`dmesg | grep tty`;
print STDOUT "Your kernel says (man dmesg)\n$dmesg\n";
#tests:
&mdmctl("ttyS");
print STDOUT "...deprecated /dev/cua* for ancient distros...\n";
&mdmctl("cua");
print STDOUT "Modem test finished.\n";
sub mdmctl {
my $prefix=$@;
print STDOUT "Testing: $prefix\*\n";
for $i (0..3) {
print STDOUT "\t\/dev\/$prefix$i\n";
open (MDM,">/dev/$prefix$i") or die;
print MDM $mdmstrng;
sleep(2);
close (MDM);
}
print STDOUT "Done $prefix\* tests.\n";
}
---end untested perl code---
--
The Toronto Linux Users Group. Meetings: http://tlug.ss.org
TLUG requests: Linux topics, No HTML, wrap text below 80 columns
How to UNSUBSCRIBE: http://tlug.ss.org/subscribe.shtml
More information about the Legacy
mailing list