Piping data into Python on the command line - Windows 2000

Christian Long christianzlong at yahoo.com
Wed Jun 25 16:28:31 EDT 2003


Hi

I'm trying to pipe data into a python program on Windows 2000, on the
command line.

Like this:
dir | myProgram.py


Here's what I tried:

== readFromStdin.py ==
#!/usr/bin.env python
import sys
print sys.sdtin.readlines()


When I run it on Linux and Windows, results differ
ls -l | ./readFromStdin.py    - Works on Linux

dir | readFromStdin.py        - Doesn't work on win2000
                             IOError: [Errno 9] Bad file descriptor

The ultimate goal is to write python scripts that I can use from
Komodo's (Python IDE) Run Command feature.  I'm running Komodo on
Windows 2000.

I want to highlight some text in Komodo, and run my command, pasting
the output of my program back in to the file I was editing in Komodo.

Komodo makes this easy with built-in commands like sort.  You just
select the "Pass Selection As Input" and "Insert Output" options,
highlight some text, type "sort" in the Run Command box, and voila,
Komodo pipes your highlighted text to sort, and pastes the sorted text
back into your editor window.

I want to write a Python program that can behave in the same way as
sort does, for use with  Komodo on Windows 2000.

Thanks!

Christian Long




More information about the Python-list mailing list