Home     My Faqts     Contributors     About     Help    

faqts : Computers : Programming : Languages : Python

FAQTs repaired & updated!
Thanks for your patience...
Entry Add Entry Alert - Edit this Entry

Did You Find This Entry Useful?

11 of 22 people (50%) answered Yes
Recently 4 of 10 people (40%) answered Yes

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

Jul 9th, 2001 19: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



© 1999-2004 Synop Pty Ltd