pipes like perl
max(01)*
max2 at fisso.casa
Tue Aug 23 16:03:57 EDT 2005
infidel wrote:
> Here's one technique I use to run an external command in a particular
> module:
>
> stdin, stdout, stderr = os.popen3(cmd)
> stdin.close()
> results = stdout.readlines()
> stdout.close()
> errors = stderr.readlines()
> stderr.close()
> if errors:
> raise Exception(''.join(errors))
>
> Maybe this will get you going in a better direction?
>
yeah thanks!
i translated as:
....
import os
....
CMD_STDIN, CMD_STDOUT, CMD_STDERR = \
os.popen3("*some_system_command*", "r")
if not CMD_STDERR.readlines():
...
*do_something*
...
for answer in CMD_STDOUT:
print answer,
...
*do_something_more*
...
else:
...
*do_something_else*
...
CMD_STDIN.close()
CMD_STDOUT.close()
CMD_STDERR.close()
....
bye
max
More information about the Python-list
mailing list