<html><head><meta name="color-scheme" content="light dark"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;">news.utdallas.edu!tamsun.tamu.edu!cs.utexas.edu!sun-barr!news2me.EBay.Sun.COM!jethro.Corp.Sun.COM!eric.arnold@sun.com Tue Mar 23 14:14:47 CST 1993
Article: 1763 of comp.lang.perl
Xref: feenix.metronet.com comp.lang.perl:1763
Path: feenix.metronet.com!news.utdallas.edu!tamsun.tamu.edu!cs.utexas.edu!sun-barr!news2me.EBay.Sun.COM!jethro.Corp.Sun.COM!eric.arnold@sun.com
From: eric.arnold@sun.com
Newsgroups: comp.lang.perl
#Subject: Re: Perl and MODEMS
Date: 23 Mar 1993 18:38:00 GMT
Organization: Sun Microsystems, Inc.
Lines: 61
Distribution: world
Message-ID: &lt;1onle8INNaq@jethro.Corp.Sun.COM&gt;
References: &lt;1993Mar22.123448.1272@sei.cmu.edu&gt;
Reply-To: eric.arnold@sun.com
NNTP-Posting-Host: animus.corp.sun.com


This worked for me on a Sun(4.1.2) with a Hayes compatible USRobotics modem:


open(MODEM, "+&gt;/dev/cua0") || die "Can't open /dev/ttyb\n";
system("stty -echo raw &gt;/dev/cua0");

$out = "ATV1E0\r";                      # make sure modem is set to
                                        # send an "OK" instead of "0"

syswrite(MODEM, $out, length($out) ) ;  # could also do non-buffered "print"
sleep(1);                               # wait for modem to respond
sysread(MODEM, $in, 1000);              # better than $i = &lt;MODEM&gt;
                                        # since it gets all data at
                                        # once, including extra newlines,
                                        # but doesn't hang, like @i = &lt;MODEM&gt;;

print "($in)\n";

if ($in =~ /OK/ ) {                     # do this instead of $in eq "OK"
                                        # because modem may send other junk
        print "OK received\n";
} else {
        print "OK NOT received\n";
}


In article 1272@sei.cmu.edu, hsm@sei.cmu.edu (Scott Matthews) writes:
&gt;
&gt;Hi everybody,
&gt;
&gt;I have tried (unsuccessfully) for the last week to get Perl to do basic data communications via a modem in the UNIX environment.  Problem is, the Perl manual we have (wall and schwartz) doesnt specify how to do this.  Could someone tell me BRIEFLY what I have to be doing?
&gt;
&gt;I had been trying something like this, but have no idea if it is right...
&gt;
&gt;#!/usr/projects/CF/bin/perl4.019
&gt;
&gt;local($in,$temp);
&gt;
&gt;$temp = "AT\n";
&gt;$in = '';
&gt;
&gt;open(MODEM, '/dev/ttyb') || die "Can't open /dev/ttyb\n";
&gt;write(MODEM, $temp, length($temp));
&gt;read(MODEM, $in, 10);
&gt;
&gt;print $in,"\n";
&gt;
&gt;if ($in eq 'OK') {
&gt;        print "OK received\n";
&gt;} else {
&gt;        print "OK NOT received\n";
&gt;}
&gt;
&gt;
&gt;any help appreciated..
&gt;scott






</pre></body></html>