[Tutor] Scripts

Daniel Yoo dyoo@hkn.eecs.berkeley.edu
Sat, 31 Mar 2001 19:45:36 -0800 (PST)


On Fri, 30 Mar 2001, Larry Lam wrote:

> How can I call and receive phone calls thru a modem using python scripts?
> How to kill a telnet section with python?

On a Unix computer, the modem is a serial device that can be opened like a
file.  On my system, it's '/dev/cua1' (COM2), so one way to send commands
to the modem would be:

###
modem = open('/dev/cua1', 'w')
modem.write('ATZ\n')
###

However, I don't have a modem anymore, so I'm unable to test any
modem-like stuff at the moment.  Windows, too, has support for serial-port
communications, and there are a few modules available that might be
helpful for you:

    http://www.vex.net/parnassus/apyllo.py?i=15173005
    http://starship.python.net/crew/roger/



About closing a telnet session: assuming that the session was opened with
telnetlib, you should be able to simply close() the connection, according
to:

    http://python.org/doc/current/lib/telnet-objects.html

Good luck to you!