<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=Content-Type content="text/html; charset=windows-1252">
<META content="MSHTML 6.00.2900.2668" name=GENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=#ffffff>
<DIV><FONT size=2>Hi gang, a strange one uncovered by a student of my 
tutorial.</FONT></DIV>
<DIV><FONT size=2></FONT>&nbsp;</DIV>
<DIV><FONT size=2>If you create the following example program, lets call it 
intest.py:</FONT></DIV>
<DIV><FONT size=2></FONT>&nbsp;</DIV>
<DIV><FONT size=2>####### intest.py #####</FONT></DIV>
<DIV>inp = raw_input()<BR>while inp != '':<BR>&nbsp;&nbsp; print 
inp<BR>&nbsp;&nbsp; inp = raw_input()</DIV>
<DIV>#######################</DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT size=2>And the following data file</FONT></DIV>
<DIV><FONT size=2></FONT>&nbsp;</DIV>
<DIV><FONT size=2>-------- Not part of in.txt -----</FONT></DIV>
<DIV><FONT size=2>6</FONT></DIV>
<DIV><FONT size=2>7</FONT></DIV>
<DIV><FONT size=2>8</FONT></DIV>
<DIV><FONT size=2></FONT>&nbsp;</DIV>
<DIV><FONT size=2>
<DIV><FONT size=2>-------- Not part of in.txt -----</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV>Then run Python from a DOS prompt like so:</DIV>
<DIV>&nbsp;</DIV>
<DIV>C:\somepath&gt; pythopn intest.py &lt; in.txt</DIV>
<DIV>&nbsp;</DIV>
<DIV>The file content is echo'd as expected.</DIV>
<DIV>&nbsp;</DIV>
<DIV>But if you start it:</DIV>
<DIV>&nbsp;</DIV>
<DIV>C:\somepath&gt; intest.py &lt; in.txt</DIV>
<DIV>&nbsp;</DIV>
<DIV>There is no output! </DIV>
<DIV>In fact, I get an error:</DIV>
<DIV>&nbsp;</DIV>
<DIV>E:\PROJECTS\Python&gt;intest.py &lt; in.txt<BR>Traceback (most recent call 
last):<BR>&nbsp; File "E:\PROJECTS\Python\intest.py", line 2, in 
?<BR>&nbsp;&nbsp;&nbsp; inp = raw_input()<BR>EOFError: EOF when reading a 
line</DIV>
<DIV>&nbsp;</DIV>
<DIV>And if you run</DIV>
<DIV>&nbsp;</DIV>
<DIV>C:\somepath&gt; intest.py</DIV>
<DIV>&nbsp;</DIV>
<DIV>You get the interactive version as expected.</DIV>
<DIV>&nbsp;</DIV>
<DIV>Why the difference with the redirected file? I am confused.</DIV>
<DIV>What am I missing? XP seems to have a different runtime </DIV>
<DIV>environment depending on how the script is run... </DIV>
<DIV>BTW This also happens under cygwin.</DIV>
<DIV>&nbsp;</DIV></FONT></DIV>
<DIV><FONT size=2>Alan G<BR>Author of the Learn to Program web tutor<BR><A 
href="http://www.freenetpages.co.uk/hp/alan.gauld">http://www.freenetpages.co.uk/hp/alan.gauld</A></FONT></DIV></BODY></HTML>