how to run python script from Unix Shell?
donn at drizzle.com
Fri Sep 7 17:43:03 CEST 2001
Quoth Peter Hansen <peter at engcorp.com>:
| Joal Heagney wrote:
|> Peter Hansen wrote:
|>| The other problem could be that your python is not
|>| really in /usr/bin (type "which python" to be sure)
|> If this is so, you may want to try the magic hack
|> #!/usr/bin/env python
| Would this find the executable if it were not in the
| path somewhere else? If not, then it doesn't solve
| the possible problem I described above.
| Besides, then you have a bunch of scripts with
| non-conventional stuff in the first line, instead of
| the "standard" #!/usr/bin/python. Probably better
| to just fix the environment to work with that, so
| you don't have to rewrite scripts you download, or
| modify scripts you upload...
python will in any case be somewhere in PATH, just not so
reliably in /usr/bin. (In fact, I have never in 7 or 8
years of using Python seen it in /usr/bin.) env does find
it in PATH, so you don't need to move python around to
accommodate scripts. (Unfortunately, env isn't always
in the same place either! but it's better than python.)
/usr/bin/env in the first line is standard.
Donn Cave, donn at drizzle.com
More information about the Python-list