[Tutor] Another Python from WINNT command line question

stuart_clemons@us.ibm.com stuart_clemons@us.ibm.com
Tue, 28 May 2002 12:15:01 -0400


--0__=0ABBE154DFCB88D58f9e8a93df938690918c0ABBE154DFCB88D5
Content-type: text/plain; charset=US-ASCII


OK,

I can run my program, foo.py, from any NT command line like this.

      c:\>f:\python22\foo.py

      which returns,  "this is foo"

So, now I want to pipe the output of foo.py to a file, spam.txt.  So I use
this command line:

      c:\>f:\python22\foo.py > spam.txt

What happens is that spam.txt is created, but it is empty (it should
contain "this is foo")

If I run my program, foo.py, from the python directory and pipe it, it
directs the output to the spam.txt file correctly.

      f:\python22> foo.py > spam.txt
      f:\python22> type spam.txt
      this is foo

What do I need to do to redirect output when I run my python program from
the non-Python installed directory ?

Thanks,

- Stuart
---------------------- Forwarded by Stuart Clemons/Westford/IBM on
05/28/2002 12:16 PM ---------------------------


Stuart Clemons
05/28/2002 11:52 AM

To:    tutor@python.org
cc:
Subject:    re: Python from WINNT command line question

Hi all:

I think figured out my solution.

While this didn't work:

      E:\WINNT4>f:\python22\python foo.py

      f:\python22\python: can't open file 'foo.py'

This worked (though I'm not sure why):

      E:\WINNT4>f:\python22\foo.py

- Stuart

---------------------- Forwarded by Stuart Clemons/Westford/IBM on
05/28/2002 12:03 PM ---------------------------


Stuart Clemons
05/28/2002 11:08 AM

To:    tutor@python.org
cc:
Subject:    Python from WINNT command line question

Hi:

Python 2.2 is installed in f:\ptython22, as are my .py program files.  I
can run my programs with no problem from the f:\python22 directory.

However, when I try to run them from another drive\directory, I get a
"can't open file foo.py" error.

I tried setting the path and PYTHONPATH environment as shown below.

What do I need to do to make this work ?   Thanks,


E:\WINNT4>path
PATH=f:\python22;f:\python22\lib

E:\WINNT4>set PYTHONPATH
PYTHONPATH=f:\python22\lib

E:\WINNT4>f:\python22\python foo.py

f:\python22\python: can't open file 'foo.py'

E:\WINNT4>



--0__=0ABBE154DFCB88D58f9e8a93df938690918c0ABBE154DFCB88D5
Content-type: text/html; charset=US-ASCII
Content-Disposition: inline

<html><body>
<p>OK,<br>
<br>
I can run my program, foo.py, from any NT command line like this.<br>
<br>
	c:\&gt;f:\python22\foo.py<br>
<br>
	which returns,  &quot;this is foo&quot;<br>
<br>
So, now I want to pipe the output of foo.py to a file, spam.txt.  So I use this command line:<br>
<br>
	c:\&gt;f:\python22\foo.py &gt; spam.txt<br>
<br>
What happens is that spam.txt is created, but it is empty (it should contain &quot;this is foo&quot;)<br>
<br>
If I run my program, foo.py, from the python directory and pipe it, it directs the output to the spam.txt file correctly.<br>
	<br>
	f:\python22&gt; foo.py &gt; spam.txt<br>
	f:\python22&gt; type spam.txt<br>
	this is foo<br>
<br>
What do I need to do to redirect output when I run my python program from the non-Python installed directory ?<br>
<br>
Thanks,<br>
<br>
- Stuart <br>
<font color="#800080">----------------------</font><font size="2" color="#800080"> Forwarded by Stuart Clemons/Westford/IBM on 05/28/2002 12:16 PM </font><font color="#800080">---------------------------</font><br>

<p><font size="2" color="#800080">To:	</font><font size="2">tutor@python.org</font><br>
<font size="2" color="#800080">cc:	 </font><br>
<font size="2" color="#800080">Subject:	</font><font size="2">re: Python from WINNT command line question</font><br>
<br>
Hi all:<br>
<br>
I think figured out my solution.<br>
<br>
While this didn't work:<br>
<br>
	E:\WINNT4&gt;f:\python22\python foo.py<br>
<br>
	f:\python22\python: can't open file 'foo.py'<br>
<br>
This worked (though I'm not sure why):<br>
<br>
	E:\WINNT4&gt;f:\python22\foo.py<br>
<br>
- Stuart<br>
<br>
<font color="#800080">----------------------</font><font size="2" color="#800080"> Forwarded by Stuart Clemons/Westford/IBM on 05/28/2002 12:03 PM </font><font color="#800080">---------------------------</font><br>

<p><font size="2" color="#800080">To:	</font><font size="2">tutor@python.org</font><br>
<font size="2" color="#800080">cc:	 </font><br>
<font size="2" color="#800080">Subject:	</font><font size="2">Python from WINNT command line question</font><br>
<br>
Hi:<br>
<br>
Python 2.2 is installed in f:\ptython22, as are my .py program files.  I can run my programs with no problem from the f:\python22 directory.<br>
<br>
However, when I try to run them from another drive\directory, I get a &quot;can't open file foo.py&quot; error.  <br>
<br>
I tried setting the path and PYTHONPATH environment as shown below. <br>
<br>
What do I need to do to make this work ?   Thanks,<br>
<br>
<br>
E:\WINNT4&gt;path<br>
PATH=f:\python22;f:\python22\lib<br>
<br>
E:\WINNT4&gt;set PYTHONPATH<br>
PYTHONPATH=f:\python22\lib<br>
<br>
E:\WINNT4&gt;f:\python22\python foo.py<br>
<br>
f:\python22\python: can't open file 'foo.py'<br>
<br>
E:\WINNT4&gt;<br>
<br>
<br>
<br>
</body></html>
--0__=0ABBE154DFCB88D58f9e8a93df938690918c0ABBE154DFCB88D5--