hi
i want to redirect python compiler messages to a file.
for example

if i run a python which has a line

a=;2

python compiler will give me an error message saying 'syntax error'
how i can fetch this error and write it to a file?

i run it with

./test.py > log.txt

but it will output the error in console.

regards

Recommended Answers

A simple > is equivalent to 1> . It redirects stdout to your file. A 2> redirects stderr. A google search with "linux redirection" should tell you all about redirection. For example, I found this [url]http://en.wikipedia.org/wiki/Redirection_%28computing%29[/url]

Jump to Post

All 3 Replies

Re: [Simple Question] redirect python compiler error to a file 80 80

In linux, you could use

./test.py 2&> log.txt
Re: [Simple Question] redirect python compiler error to a file 80 80

WoW, thanks alot Gribouillis :D
i greatly appreciated.
but can you please tell me the difference between mine and yours?
what the "2" is doing here?

regards

Re: [Simple Question] redirect python compiler error to a file 80 80

A simple > is equivalent to 1> . It redirects stdout to your file. A 2> redirects stderr. A google search with "linux redirection" should tell you all about redirection. For example, I found this http://en.wikipedia.org/wiki/Redirection_%28computing%29

Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.18 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.