[Gllug] Modem Commands
Rob Andrews
rob at impure.org.uk
Sun Feb 10 00:55:06 UTC 2002
[09-Feb-2002 23:56.57 (GMT) / Iain Conochie]
> > Secondly you could get chat to multi-expect more than one thing. Like
> > "CONNECT <speed>", but since modems don't always negotiate at the same rate,
> > this may end up spitting out any speed. You have to predict all of them. And
> > trust me, there are lots. This isn't a pleasant method.
> In other words I have to know the connect speed before I connect. NOt
> really the purpose of the exercise(sp???)
Not quite... modems will always connect at certain speeds, but if you can
predict each one, and have chat accept it... i.e.
CONNECT 9600
CONNECT 12000
CONNECT 14400
CONNECT 15000
etc.
Then chat will report that. If you don't cover the full scope, it'll timeout
and disconnect.
> > Or you could not use chat. This is the third "hidden" option I don't usually
> > suggest, but try either expect or perl with Expect.pm, then get it to issue
> > a syslog output with something like "connected at $speed". This seems the
> > tidiest method. And both expect and perl's Expect.pm are a doddle to learn.
> Ah..... - chat basically talks to the modem yeah?? TBH I am getting lazy
> and can't really be bothered to muck around too much with this. But I do
> remeber a while ago I was getting connection speed logged through syslog
> and I was wondering if I was being dumb or something....
chat does the talking, yes. But from chat's point of view, it's getting from
STDIN and throwing to STDOUT, so you could use a shellscript if you wanted.
Or you don't even have to use [Ee]xpect, i.e.
#!/usr/bin/perl -w
my $input;
print "ATZX4S95=255\n";
$input=<STDIN>;
if($input=~/^OK/i) {
print "ATDTxxxxxxxxx\n";
} else {
die "Ouch! Modem didn't like our reset";
}
$input=<STDIN>;
if($input=~/^CONNECT (.*)$/i) {
print STDERR "Connected at $1 bps\n";
} else {
die "Modem failed to connect";
}
exit 0;
(although in this example, you won't get anything in syslog regarding
connect speed, you'll need to get it to output to syslog, try perldoc
Sys::Syslog for how)
--
nine <e> rob at impure.org.uk <pgp> 0x8bb5c71e <w> http://impure.org.uk/
--
Gllug mailing list - Gllug at linux.co.uk
http://list.ftech.net/mailman/listinfo/gllug
More information about the GLLUG
mailing list