pound bang (#!) problem...

Carel Fellinger cfelling at iae.nl
Thu Dec 30 15:08:17 EST 1999


Orlando Vazquez <ovazquez at sprint.ca> wrote:

> for simplicity's sake say this is my preprocessor (preprocessor.py):

>    #!/usr/local/bin/python
>    import sys
>    s = sys.stdin.read() # read until EOF and store in "s"
>    print s              # print what we read

> and my un processed file (index.pyhtml) looks like..
>    #!./preprocessor.py

I'm afraid the shebang thing isn't recursive.
In index.pyhtml you should use something like:
#!/usr/local/bin/python /perhaps-a-path/preprocessor.py

> If my UNIX skills serve me correctly running:
>    ./index.pyhtml

> should be the same as running:
>    ./preprocessor.py < index.pyhtml

> Right? But, when I do run index.pyhtm alone it just sits there and does

I'm afraid not. It is more like:
./preprocessor.py index.pyhtml

so index.pyhtml ends up as a argument to preprocessor.py, therefor you
have to use something like open(sys.argv[1]) in preprocessor.py as someone
else already suggested.
-- 
groetjes, carel



More information about the Python-list mailing list