Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Calling a python script from command line without typing "python" first

Question: In command line, how do I call a python script without having to type python in front of the script's name? Is this even possible?


Info:

I wrote a handy script for accessing sqlite databases from command line, but I kind of don't like having to type "python SQLsap args" and would rather just type "SQLsap args". I don't know if this is even possible, but it would be good to know if it is. For more than just this program.

like image 656
Narcolapser Avatar asked Aug 03 '10 20:08

Narcolapser


1 Answers

You can prepend a shebang on the first line of the script:

#!/usr/bin/env python

This will tell your current shell which command to feed the script into.

like image 67
efritz Avatar answered Sep 23 '22 06:09

efritz