Question about stdin and PATHEXT on Windows XP

Lasse Vågsæther Karlsen lasse at vkarlsen.no
Sat Oct 1 14:02:17 EDT 2005


I got a loop like this:

     while True:
         line = sys.stdin.readline()
         if not line:
             break
         line = line.rstrip()
         log_message(options.channel_name, line)
         print line

this loop will read text if I execute it from a command prompt like this:

dir | python.exe log.py

however, since I've set PATHEXT to contain .PY, I tried this:

dir | log.py

which ended up with the loop just skipping.

Does anyone know how to fix this problem ? Being able to use PATHEXT 
execution (just execute python file directly) and still being able to 
grab stdin? I assume that since there is some magic involved in invoking 
python.exe here, stdin gets munged on the way.

-- 
Lasse Vågsæther Karlsen
http://usinglvkblog.blogspot.com/
mailto:lasse at vkarlsen.no
PGP KeyID: 0x2A42A1C2



More information about the Python-list mailing list