[Tutor] [tutor] run a program and direct it's print file to a file?
lie.1296 at gmail.com
Sat Oct 25 22:58:04 CEST 2008
On Sat, 25 Oct 2008 07:56:53 -0400, Fast Primes wrote:
> I'm very rusty. From a linux box, I want to run a program X.py after or
> while setting it's list output to a file L.txt. How do I do that please?
I think this is a linux question more than python question. In Linux,
it's easy to do stdin-stdout-stderr redirection.
python script.py > output.txt
If you're trying to redirect the output programmatically from inside the
python program, instead of using the shell service for I/O redirection,
do something like this:
sys.stdout = open('output.txt', 'w')
More information about the Tutor