Nothing happens when executing a python shebang script in /usr/local/bin/

595 views Asked by At

Nothing happens when executing a python shebang script in /usr/local/bin/

Hopefully someone can help me. So i made a simple python program called test for testing out shebang scripts(I have used chmod to make it executable):

#!/usr/bin/python
print "hello"

after i copied it to /usr/local/bin/ i tried to call it by typing in my shell:test but nothing happened... (There were no errors)

Adrian

2

There are 2 answers

2
Blender On BEST ANSWER

test is actually a shell builtin:

$ type test
test is a shell builtin

Rename your script to something else or run it directly by executing /usr/local/bin/test.

0
c9mm9dore On

Blender is right: 'test' is an unfortunate name choice for your file. There is already a shell builtin function called 'test'. It would be the same if you tried to make a python script called 'ls'. The reason it works when executing './test' is due to the fact that './' tells the shell to make the current directory first in the executable path. If you rename your python script to 'bangtest' and make sure it has executable permissions (chmod +x bangtest), it will work in the manner you desire.