469,323 Members | 1,560 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,323 developers. It's quick & easy.

Question about stdin and PATHEXT on Windows XP

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:la***@vkarlsen.no
PGP KeyID: 0x2A42A1C2
Oct 2 '05 #1
1 1375
Lasse Vågsæther Karlsen wrote:
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.

--
Lasse Vågsæther Karlsen
http://usinglvkblog.blogspot.com/
mailto:la***@vkarlsen.no
PGP KeyID: 0x2A42A1C2
Oct 2 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

9 posts views Thread by It's me | last post: by
3 posts views Thread by Brent W. Hughes | last post: by
11 posts views Thread by Tom Willis | last post: by
reply views Thread by Joe Burnett | last post: by
3 posts views Thread by Mike Tammerman | last post: by
6 posts views Thread by Charlie Zender | last post: by
27 posts views Thread by R2D2 | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by Gurmeet2796 | last post: by
reply views Thread by mdpf | last post: by
reply views Thread by harlem98 | last post: by
reply views Thread by listenups61195 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.