Shebang line problems and python
Ben Finney
ben+python at benfinney.id.au
Wed Sep 16 23:47:30 EDT 2009
Blaine <brlafreniere at gmail.com> writes:
> Scripts that have "#!/usr/bin/python" at the top do not parse
> correctly. Bash treats scripts with that shebang as if they are bash
> scripts.
When you run a file as a command, it's not Bash that decides how to run
it; the kernel has the job of understanding how to run the program. Bash
simply ignores the shebang line, since it is (intentionally) a comment
as far as Bash is concerned.
> E.g.:
> blaine at attila ~/apps/rs-mu $ /usr/sbin/env-update
> /usr/sbin/env-update: line 6: import: command not found
> /usr/sbin/env-update: line 8: syntax error near unexpected token `('
> /usr/sbin/env-update: line 8: `def usage(status):'
As usual, it helps if we can see the actual content of a complete
minimal example.
Here's mine::
=====
$ echo $SHELL
/bin/bash
$ cat ./shebang-test
#! /usr/bin/python
import sys
sys.stdout.write("Hello, world.\n")
$ ./shebang-test
Hello, world.
=====
Does the above session work differently for you?
Can you come up with a complete, minimal example that shows the
behaviour you're describing?
--
\ “Of course, everybody says they're for peace. Hitler was for |
`\ peace. Everybody is for peace. The question is: what kind of |
_o__) peace?” —Noam Chomsky, 1984-05-14 |
Ben Finney
More information about the Python-list
mailing list