os module question

sean sean_berry at cox.net
Sun Mar 28 00:36:01 EST 2004


You might try

for line in os.popen("fortune -f").readlines():
     print line.strip()

os.system() always seems to return all output so I don't know why that
doesn't work.

I am sure someone better versed in Python will shed some light.



"Rasputin" <noone at nowhere.net> wrote in message
news:pan.2004.03.28.04.16.59.189016 at nowhere.net...
> On the bash shell if I type "fortune -f" it outputs:
> ___% /usr/share/games/fortunes
>     ___% zippy
>     ___% fortunes
>     ___% fortunes2-o
>     ___% limerick-o
>     ___% startrek
>     ___% fortunes2
>     ___% unamerican-o
>     ___% fortunes-o
>     ___% linuxcookie
>
> When I type os.system("fortune -f") in python it outputs:
> ___% fortunes
> ''
>
> How do I bypass it and get the orginal output?





More information about the Python-list mailing list