problem executing python scripts in cygwin bash shell

D-Man dsh8290 at rit.edu
Fri Apr 6 12:24:52 EDT 2001


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