Reputation: 407
I am trying to make either a .bat or .exe file to execute a python script in linux (Raspbian). I would want to have an icon on the desktop which will be clicked (touch screen) and will then execute the python script.
The python script would need 'sudo' authorization... so if I wanted to run in terminal:
sudo python filelocation/name.py
Thanks!
Upvotes: 1
Views: 12329
Reputation: 6257
Use a .desktop
file as nodakai already mentioned.
To have the python file executed with root permissions, either
gksudo python program.py
. This will ask the user for the password in a normal window, no terminal involved.sudoers
file, and use the usual sudo python program.py
. (If you use this, make sure your program doesn't allow the user to do whatever they want, but only does the specific tasks you want the user to be able to do as root.)Upvotes: 3
Reputation: 8033
I've never used Raspbian myself, but I guess you can follow the standard procedure to add a custom icon to your desktop:
Upvotes: 4
Reputation: 113998
name.py
#!/bin/python
.....
then set the permissions (all the following commands are done in the terminal)
$ chmod a+x name.py
then you can run it as
$ ./name.py
if you wanted to run it as sudo you would do
$ sudo ./name.py
Upvotes: -1