faqts : Computers : Programming : Languages : Python

+ Search
Add Entry AlertManage Folder Edit Entry Add page to http://del.icio.us/
Did You Find This Entry Useful?

15 of 29 people (52%) answered Yes
Recently 5 of 10 people (50%) answered Yes

Entry

how would i run a command to an applicatation like telnet?

Jul 9th, 2001 02:01
Joonas Paalasmaa, chase cobb,


Use popen2 module 
http://www.python.org/doc/current/lib/module-popen2.html

Example:

import popen2

in, out = popen2.popen2("sort")


out.write("1\n")
out.write("2\n")
out.write("4\n")
out.write("3\n")

print in.readline(),
print in.readline(),
print in.readline(),
print in.readline(),

prints 1 2 3 4