pythonwindowshttp-redirectelasticsearchpyes

Unable to redirect python script result to a text file in windows


Here is my python code.I'm trying to do elastic search in python.

from pyes import *
from pyes.mappings import *
conn = ES('http://search.twitter.com/search.json?q=poplio')
conn.indices.create_index("test-index")

I'm trying this tutorial pyes

The issue is when i try to run this python script in windows i get a detailed message on msdos prompt which i don't know if its an error or any thing else.

So i tried to redirect that message to a text file but i don't see any thing in that file.

Here is how i redirect the output of script

python script.py > log.txt

But log.txt is empty.

What is going wrong.


Solution

  • It might be printing those messages to STDERR. Try doing the following:

    python script.py > log.txt 2>&1

    This will redirect the STDERR to STDOUT as well. You should see those messages then.