[Tutor] shebang problem

Rick Pasotto rick at niof.net
Sun Nov 5 01:30:16 CET 2006

On Sat, Nov 04, 2006 at 06:11:03PM -0600, Brian van den Broek wrote:
> Hi all,
> I'm still getting comfortable with Linux and this might be an OS
> rather than a python problem.
> I am trying to make a script directly executable. I've reviewed the
> 2nd ed of the Nutshell, and I cannot work out what I'm doing wrong.
> I'm running ubunutu 6.10 (edgy eft). Here's a copy past of my command
> line:
> brian at gottlob:~/test$ which python
> /usr/bin/python
> brian at gottlob:~/test$ ls -la shebangtest.py
> -rwxr-xr-- 1 brian brian 68 2006-11-04 02:29 shebangtest.py
> brian at gottlob:~/test$ cat shebangtest.py
> #!/usr/bin/python
> if __name__ == '__main__':
>      print "It works"
> brian at gottlob:~/test$ shebangtest
> bash: shebangtest: command not found
> brian at gottlob:~/test$ shebangtest.py
> bash: shebangtest.py: command not found

Most likely the current directory is not in your path. Type in
'echo $PATH' and look for a single period between colons. It is correct
*not* to have the current directory in your path for security reasons.

Now type in: './shebangtest' and your program should run. Putting the
'./' in front tells bash to use the command in the current directory.

"Rousseau was convinced that God, nature and man were wrong. I know
 that this opinion still sways many minds, but mine is not one of
 them." -- Frédéric Bastiat (1801-1850)
    Rick Pasotto    rick at niof.net    http://www.niof.net

More information about the Tutor mailing list