Question about stdin and PATHEXT on Windows XP

  • Thread starter =?ISO-8859-1?Q?Lasse_V=E5gs=E6ther_Karlsen?=
  • Start date
?

=?ISO-8859-1?Q?Lasse_V=E5gs=E6ther_Karlsen?=

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.
 
?

=?ISO-8859-1?Q?Lasse_V=E5gs=E6ther_Karlsen?=

Lasse said:
I got a loop like this:
<snip>

Ok, I've found some information. I don't like the answer but it doesn't
seem to be any good way to do this without hacking it one way or the other.

If someone has a brilliant answer that isn't in google yet, please let
me know.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,780
Messages
2,569,607
Members
45,240
Latest member
pashute

Latest Threads

Top