M
max(01)*
hi.
in perl i can do this:
....
if (open (MYPIPE, "*some_system_command* |"))
{
...
*do_something*
...
while ($answer = <MYPIPE>)
{
print $answer;
}
...
*do_something_more*
...
}
else
{
...
*do_something_else*
...
}
....
but i do not know how to do it in python, because "if *command*:" gives
syntax error.
moreover, if i use
....
import os
....
try:
MYPIPE = os.popen("*some_system_command*, "r")
...
*do_something*
...
for answer in MYPIPE:
print answer,
MYPIPE.close()
...
*do_something_more*
...
except:
...
*do_something_else*
...
....
it doesn't work, since "*do_something*" and *do_something_more* are
always executed (it seems like
MYPIPE = os.popen("*some_system_command*", "r")
does not raise any exception even if *some_system_command* does not
exist/work...
any help?
thanks a lot
max
in perl i can do this:
....
if (open (MYPIPE, "*some_system_command* |"))
{
...
*do_something*
...
while ($answer = <MYPIPE>)
{
print $answer;
}
...
*do_something_more*
...
}
else
{
...
*do_something_else*
...
}
....
but i do not know how to do it in python, because "if *command*:" gives
syntax error.
moreover, if i use
....
import os
....
try:
MYPIPE = os.popen("*some_system_command*, "r")
...
*do_something*
...
for answer in MYPIPE:
print answer,
MYPIPE.close()
...
*do_something_more*
...
except:
...
*do_something_else*
...
....
it doesn't work, since "*do_something*" and *do_something_more* are
always executed (it seems like
MYPIPE = os.popen("*some_system_command*", "r")
does not raise any exception even if *some_system_command* does not
exist/work...
any help?
thanks a lot
max