problem executing python scripts in cygwin bash shell

Tom Satter tsatter at purecode.com
Fri Apr 6 17:33:35 EDT 2001


I like to use the following for my python scripts since
this works on Cygwin, MKS, Linux, and Solaris...


#!/bin/sh
"""true" -*- python -*-
exec python -tt `echo $0 | sed -e 's@\\\\@/@g' -e
's@^/cygdrive/\([a-zA-Z]\)/@\1:/@' -e 's@^//\([a-zA-Z]\)/@\1:/@'` ${1+"$@"}

Script Comment goes here...

"""
Put the script here...

--

tom -- just plain old tom
tsatter at purecode.com
"D-Man" <dsh8290 at rit.edu> wrote in message
news:mailman.986574311.27809.python-list at python.org...
> On Fri, Apr 06, 2001 at 03:55:36AM +0100, John J. Lee wrote:
> | On Thu, 5 Apr 2001, D-Man wrote:
> | [...]
> | > #!/bin/bash
> | >
> | > //d/apps/Python20/python.exe $*
> | [...]
> |
> | Aha!  Good idea.  Perhaps even better:
> |
> | #!/bin/sh
> |
> | temp = "$@ "
> | //d/apps/Python20/python `cygpath -w $1` ${temp#* }
>
> There's a good idea.  I've always been annoyed when I wanted to run
> something with an absolute path (ie /home/derrick/foo.py) and
> python.exe couldn't handle it (any windo~1 app, really).  I tend to
> use the commandline for that particular situation though (ie  python
> `cygapth --windows --absolute /home/derrick/foo.py`).  That's cool
> using the script to fix the first argument regardless.
>
> How about this instead (untested yet) :
>
> # convert the script name to a windows path
> cmd = `cygpath --windows --absolute $1`
> # remove this script and the (real) script name from the arg list
> shift 2
> # run python on the (real) script with all other args intact
> //d/apps/Python20/python $cmd $*
>
>
> A little more explicit in what it is doing, rather than using
> perl-like symbols.
>
> The main problem I've had with too many script layers is losing
> quoting or escaping if, for example, there are spaces or other weird
> characters.  Then the windows apps get the wrong data sent in because
> the shell treats it differently.
>
> -D
>
>





More information about the Python-list mailing list