How do I make python programs run without entering the command python?
I want to be able to do
sudo ./program.py instead of always having to do sudo python program.py What do I need to change? |
You need to add a python 'shebang' to the beginning of your script (so that the system knows how to interpret the commands)
Quote:
Quote:
with the scripts and running ./yourscript.py or you can place you scripts in a certain directory and add it to your $PATH. btw, are you sure you really need to run your python programs using sudo? |
sweetness, thanks man.
|
I'm seconding sycamorex's concerns about running python programs with sudo. Unless the you've spent special care hardening the scripts, it's almost guaranteed that you have a $PATH substitution or an injection vulnerability.
|
Alternative
You can install ipython for realtime action
http://ipython.scipy.org/moin/ I used this when I want to see what my program is doing. Also it gives you all the classes and object information. Here is an example: In [1]: import os In [2]: os. Display all 221 possibilities? (y or n) os.__all__ os.__builtins__ os.__class__ os.__delattr__ os.__dict__ os.__doc__ os.__file__ os.__getattribute__ os.__hash__ os.__init__ os.__name__ os.__new__ os.__reduce__ os.__reduce_ex__ os.__repr__ os.__setattr__ os._copy_reg os._Environ os._execvpe os._exists os._exit os._get_exports_list os._make_stat_result os._make_statvfs_result os._pickle_stat_result os._pickle_statvfs_result os._spawnvef os.abort os.access os.altsep os.chdir os.chmod os.chown os.chroot |
I guess I'm in the habit of running commands with sudo. I'm thinking that since the python program opens up a socket that it may need root privileges. But yeah, I'll try running it as user. Unless there is a group I can add user to so that he can open sockets.
|
All times are GMT -5. The time now is 09:45 PM. |