SUMMARY: Switching on and off auto answer on a modem

From: Donald Ballance (
Date: Thu May 11 1995 - 19:44:44 CDT

Dear Sun Managers,

Once again a quick and accurate response. Thanks to all.
My original question was:

> I would like to have a script that turns on the Auto Answer feature of
> a modem in the evening and turns it off again in the morning.
> I know I will be able to do this by setting up a cron job at the times I
> require but what I don't know how to do is to talk to the modem. tip seems
> only to work in an interactive mode, so I can't write a script to
> "tip hardwire" to switch it on or off.
> Any suggestions gratefully received.

I forgot to mention that this is on a machine running Solaris 2.4, but in
this case there does not seem to be any difference in solution.

I received 18 responses. These can be summarised as follows:
  2 "MeToo" ... please send summary
  4 use echo directly to the modem port
  1 set up fake UUCP entry and pass the ATs0=0 or ATs0=1 files as parameters
  1 use D. Bernstein's pty package
  3 use expect to get round the limitation in tip
  1 re-write tip to get round limitation of interactive use
  1 use hylafax modem software
  2 use KERMIT and write a script
  1 switch getty on/off using /etc/ttytab
  1 use echo directly to the modem port or switch getty on/off
  1 use kermit, cu or switch getty on/off
I have chosen the simplest method and have implemented two short scripts
to turn the modem on or off:

# modem_on
# Switches modem on /dev/cua/a to Auto Answer Mode
echo "AT S0=1" > /dev/cua/a

# modem_off
# Switches off Auto Answer Mode on modem on /dev/cua/a
echo "AT S0=0" > /dev/cua/a

and I then call them via the cron. I repeatedly call the modem_off
hourly during the time I wish to answer the phone since the modem
may be busy at the time of the command is executed.

I have not tried other suggestions since using echo met my requirements.
Full details of the suggested solutions are given below.

Thanks to:

Michael Ramchand Owner <>
Claus Assmann <>
Mark <>
Dave Langston <>
Torsten Metzner <>
raoul@MIT.EDU (Syed Zaeem Hosain)
Henry Unger <> (Stefan Jon Silverman)
Dave Wagle <> (Glenn Satchell - Uniq Professional Services) (Ted Whitely) (Jerry Springer) (Dave Haut)
grevemes@VTC.TACOM.Army.Mil (Steven Grevemeyer) (John Malick)

Donald Ballance,
Centre for Systems and Control,
Department of Mechanical Engineering,
University of Glasgow,
Glasgow. G12 8QQ.
Tel: +44 141 339 8855 Ext. 5187
Direct: +44 141 330 5187
Fax: +44 141 330 4343

From: Dave Langston <>
Solution: ECHO

I've had success by simply echo'ing the AT commands directly
to the modem via the /dev/ttya serial port.

For example:

echo "AT S0=1" >! /dev/ttya Will cause the modem to answer
echo "AT S0=0" >! /dev/ttya Will allow me to answer.

I've put the lines above into scripts: "igetit" and "ugetit"
and have the option of running them whenever I choose or just
letting cron control things.

Dave Langston
CAD-CAM Design Specialist
Beckman Instruments, Inc.


From: (Syed Zaeem Hosain)
Solution: ECHO

The method is:

        (stty 38400 ; echo "ATS0=0") > /dev/cua0

in the morning to turn off auto-answer. Also add any other AT command
for your modem if that specifically turns off auto-answer in addition
to the above AT sequence.

Note that when you are turning OFF the auto-answer in the morning,
there may be someone logged in, so the echo will fail. So you may want
cron to actually send that sequence of characters a number of times -
spaced every 30 minutes or hour. Sending these characters that often
will not cause anything else to fail.

And, of course, in the evening, do:

        (stty 38400 ; echo "ATS0=1") > /dev/cua0

to turn on the auto-answer.

Of course, change the above to use whatever baud rate you actually want
on the serial line (not the modem connect rate) as well as the actual
output serial port if it is not cua0.

Remember to use the "cua0" or "cua1" device for output rather than the
"ttya" or "ttyb" devices. On a Sun, this is how you avoid conflict with
the getty process.


Syed Zaeem Hosain P. O. Box 610097 (408) 441-7021
Z Consulting Group San Jose, CA 95161

From: Henry Unger <>
Solution: ECHO

I suppose you could do somthing like this:

to enable auto answer:

echo "ATS0=1\r" > /dev/cua/?

to disable auto answer:

echo "ATS0=0\r" > /dev/cua/?

The other way is to use pmadm to enable/diable the port.


From: (John Malick)
Solution: ECHO

You may try to use cron like you mentioned but since tip is interactive, try;

Write a script which echoes the proper command to the modem: ie..

echo "ats0=1" > /dev/"modem port"

Write another script to disable it.

The modem port is your call out port, ie. /dev/cua0, SunOS or /dev/cua/a, Solaris

John Malick - Systems Engineering *
Star Systems Engineering *
984 Grantley Road *
York, PA. 17403 *
(717) 854-5911 Phone *
(717) 843-0091 Fax * Email *

From: Michael Ramchand Owner <>
Solution: Fake UUCP

You could easily cheat by setting up a fake dialer device in you uucp setup.

i.e create fake hosts in /etc/uucp/Systems called auto_on and auto_off:

auto_on Any ON 38400 <your modem number> "" \r ogin:--ogin: xxx word: xxx
auto_off Any OFF 38400 <your modem number> "" \r ogin:--ogin: xxx word xxx

create entries in your /etc/uucp/Devices:

ON cua/a (or b) - 38400 answer-on
OFF cua/a (or b) - 38400 answer-off

then create entries for these dialers in your /etc/uucp/Dialers file.

If you have a hayes you need to set S0=0 to not answer and s0=1 to answer. So using hayes as an example (simply edit the modem type you have)

answer-off =,-, "" \dA\pTE1V1X1Q0S0=0S2=255S12=255\r\c OK\r \EATDT\T\r\c CONNECT ^^^

answer-on =,-, "" \dA\pTE1V1X1Q0S0=1S2=255S12=255\r\c OK\r \EATDT\T\r\c CONNECT ^^^

Set your cron to cu auto_on in the evening, and auto_off in the morning.

The cu will always fail as you will be dialing the modems number so it will be busy.

I am sure you could do this without a number at all, but the above is fairly sure to work.


From: Claus Assmann <>
Solution: PTY Package

use the pty package from D. Bernstein (we have done that here)
to simulate interactive mode.


Claus Assmann

From: Mark <>
Solution: EXPECT

This is a job for expect(1), and the scripts you need would mostly be included
in the examples that come with it, with maybe a mod or two to customise. In
particular the modem dialer script could be easily changed to just modify
your modem settings.

You can get expect from in the languages/tcl directory.


From: (Glenn Satchell - Uniq Professional Services)
Solution: EXPECT

Get hold of "expect" - this is a public domain program tha tis designed
for exactly this type of function. Use archie to find an anonymous ftp
site near you.

There is a new book out by O'Reilly, "Exploring Expect" which is of
great use to anyone who wants to create expect scripts.


Glenn Satchell            | There's  a fine  line
Uniq Professional Services Pty Ltd  ACN 056 279 335  | between  fishing  and
PO Box 70, Paddington, NSW 2021, (Sydney) Australia  | standing on the shore
Phone 02 380 6360 Pager 016 287 000 Fax 02 380 6416  | looking like an idiot.

---------------------------------------------------------------------- From: (Ted Whitely) Solution: EXPECT

My suggestion would be to use the expect program found on the internet. With this package, you can write programs that deals with interactive programs such as telnet, passwd etc.

I am not sure of the exact location of expect on the internet but it can be found using archie.

############################################################################## # Ted Whitely CAD/CAE TECH Support # # System Administrator Focus Hope # # Systems Department Center for Advanced Technologies # # Internet: CAT/H-Building # # URL: http:/ 1400 Oakman Boulevard # # Phone: (313) 494-4490 Detroit, MI 48238 # # FAX #: (313) 494-4281 U.S.A. # ##############################################################################

---------------------------------------------------------------------- From: Torsten Metzner <> Solution: Re-write tip

4 years ago we had the same problem. One of the guys here modified the source code of tip, to get the desired result. He "wrote" a program, let call it auto_answer, which set the value of the auto-answer register of your modem. If you don't get another solution I can send you the source but remember:

(1) It was a fast and short "hack" (2) Only tested under SunOS4.1.1 ( SunOS4.1.3 ? ). (3) Bad documentation of the source code (4) Only a very short README in german, but I can translate it . (5) I think you had to modify the source code a little bit, because our short "hack" was especially for the very old Discovery 2400E - modems. Setting the s0 register of this modem. But this should be easy.

Hope this helps,

Torsten. My address : Torsten Metzner E-Mail: Rechnerbetreuung Mathematik Tel.: +49 5251 603898 or Universitaet-GH Paderborn Tel.: +49 5251 602634 FB 17 - Mathematik Fax : +49 5251 603836 Warburger Str. 100 33098 Paderborn Germany

---------------------------------------------------------------------- From: raoul@MIT.EDU Solution: hylafax modem software

Install the hylafax modem software, available from It provides good fax and data answering capability, and you can disable the modem at will by starting or stopping the faxgetty. The other easy way is to disable the getty entry in /etc/ttytab on a basic setup, and do "kill -HUP 1", then re-enable it the next day.

Nico Garcia My opinions are my own, not MIT's or my employer's or my cat's (Well, maybe my cat's....)

---------------------------------------------------------------------- From: (Stefan Jon Silverman) Solution: KERMIT

i use kermit, ".kermrc" scripts can be written to talk to the modem and then automatically exit. i use one to make sure that the modem has really been hung up before re-initiating a C/SLIP connection.

hope this helps...


b c++'ing u,

%-) sjs

Stefan Jon Silverman - President SJS Associates, N.A., Inc. 572 Chestnut Street Distributed Systems Architecture & Implementation San Francisco, Ca. 94133 Phone: 415 989 2741 E-mail: Cell: 415 298 6568

---------------------------------------------------------------------- From: (Jerry Springer) Solution: KERMIT

Donald, If you can get a copy of kermit, then you call kermit from in a script to send the appropriate at sequences to your modem.

Jerry Springer Phone: (516) 746-7777 Ext. 167 Ergonomics Group/ValCom Fax: (516) 741-0145 191 Herricks Rd. Internal Email:springer@ergo Garden City Park,NY 11040-5236 External

---------------------------------------------------------------------- From: grevemes@VTC.TACOM.Army.Mil (Steven Grevemeyer) Solution: GETTY (/etc/ttytab)

you can have a script change the "on remote" to "off remote" in the /etc/ttytab file and then signal the inetd process to turn on and of the TR line on the modem. (if TR is off the modem shouldn't answer the phone"


---------------------------------------------------------------------- From: (Dave Haut) Solution: ECHO or GETTY


Why don't you just write a script to disable getty instead and configure the modem to only pickup the phone when DTR from the Sun is asserted ???

If you still want to send commands to the modem, just echo them to the serial port.


echo "ats0=0&w" > /dev/ttya

Hope this helps

--------------------------------- _ /| Dave Haut \,o.O' Sys Admin =(___)= EXAR Corporation U (408) 434-6400 x3462 ---------------------------------

---------------------------------------------------------------------- From: Dave Wagle <> Solution: KERMIT or CU or GETTY

both kermit and cu can be used as with scripts. Alternately, you may just want to turn the getty off and on, and leave the modem alone, although that may not work for your system . . .




This archive was generated by hypermail 2.1.2 : Fri Sep 28 2001 - 23:10:24 CDT