Would you mind perhaps show an example running an interactive command like su 
and show how to send input to the commands waiting propmts?

-----Original Message-----
From: linuxian iandsd <[EMAIL PROTECTED]>
Sent: Sunday, March 16, 2008 3:17 PM
To: tutor@python.org
Subject: Re: [Tutor] how to get response from os.system()

i guess that was too short tutorial well, here is an example from a live
session on the interpreter.

[EMAIL PROTECTED] ~]# python
Python 2.5.1 (r251:54863, Nov 23 2007, 16:16:53)
[GCC 4.1.1 20070105 (Red Hat 4.1.1-51)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>>
>>> cmd='ping -c 1 localhost'
>>> import os
>>> a=os.popen(cmd)
>>> print a
<open file 'ping -c 1 localhost', mode 'r' at 0xb7f1c728>
>>> print a.read()
PING serv.kontactel.loc (127.0.0.1) 56(84) bytes of data.
64 bytes from serv.kontactel.loc (127.0.0.1): icmp_seq=1 ttl=64 time=0.134ms



[The entire original message is not included]
_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor

Reply via email to