difference between invocation of python script on unix and microsoft?

Roberto Lupi Roberto.Lupi at ascu.unian.it
Wed Dec 8 11:46:51 EST 1999


In article <000201bf3ff0$f34bdf40$3acbd9c2 at peridot.optichrome.com>, 
a.eyre at optichrome.com says...
> > I recently installed perl to my laptop with NT, the README says that 
> > redirection won't work with the standard shell (CMD.EXE on NT, 
> > COMMAND.COM on Win9x).
> 
> Odd. Works fine here (NT4 - SP4 - cmd.exe):

Sorr,y I haven't expressed my tought cleanly.


The ActivePerl FAQ says:

---- 8< ---- CUT HERE ---- 8< ----

For Windows NT 4.0, the coolest method is to use associated file types 
(see How do I associate Perl scripts with perl?). If you've associated 
Perl scripts with the .pl extension, you can just type the name of your 
file at the command line and Windows NT will launch perl.exe for you. If 
you change the PATHEXT environment variable to include .pl files, like 
this:



    SET PATHEXT=.pl;%PATHEXT%

you can just type the file name without an extension, and Windows NT will 
find the first .pl file in your path with that name. You may want to set 
PATHEXT in the System control panel rather than on the command line. 
Otherwise, you'll have to re-enter it each time the command prompt window 
closes.

Given this setup, you can have a Perl script called cat.pl that looks 
like this:



    while ( <> ) {
        print;
    }

and you can invoke it on the command line like this:



    cat myfile.txt

However, you can't invoke it with I/O redirection, like this:



    cat < myfile.txt
    cat myfile.txt | more

although it looks like you should be able to (this is a limitation of 
Windows NT). Your script can be in your path or you can provide a path to 
the file.

---- 8< ---- CUT HERE ---- 8< ----

The last part is particularly interesting.

-- 
Roberto Lupi



More information about the Python-list mailing list