How to install python scripts as ROOT?

Forum rules
Before you post please read this

How to install python scripts as ROOT?

Postby JaZZyCooL on Sat Dec 08, 2012 4:24 pm

hello guys,
I am using Linux Mint just for the purpose of programming and linux experience but the problem is whenever I want to open any python script I have to define the path related to the script that is

Code: Select all
cd ~/Documents
./python.py


What should I do to open directly bu just typing in "./scriptname.py". Somebody suggested to save the things as ROOT. Can you guys help me find a way to save scripts as root or open scripts this way "./Scriptname.py"
JaZZyCooL
Level 1
Level 1
 
Posts: 46
Joined: Thu Dec 06, 2012 5:37 pm

Linux Mint is funded by ads and donations.
 

Re: How to install python scripts as ROOT?

Postby xenopeek on Sat Dec 08, 2012 6:09 pm

Well, I'd toss that advice out with the dirty dishes. There are plenty of ways to run a Python program without you needing to put it in a system directory. A couple of options:

- Create a directory called "bin" in your user's home directory. Put your script there. That directory will be added to your path automatically; see your .profile file if you want to confirm. So if you have the file myscript.py in your bin directory, instead of doing "cd ~/bin" and then "./myscript.py", you can just do "myscript.py" (notice the absence of ./ at the front, as that would be telling BASH to find the script in your current directory).

- Just browse to it with your file browser and double-click it to start it. Your file browser will ask if it should run it, or run it in a terminal (so you can see the output if it is a console script; just be sure to have a "press any key to continue" step at the end of your script).

- Add an entry to the menu from which to start your script (right-click the menu button to be able to edit your menu).

- Run the script from your IDE. I like Geany.
Image
Linux Mint 14 Nadia / 64-bit / Cinnamon
User avatar
xenopeek
Level 20
Level 20
 
Posts: 10505
Joined: Wed Jul 06, 2011 3:58 am
Location: The Netherlands

Re: How to install python scripts as ROOT?

Postby JaZZyCooL on Sat Dec 08, 2012 8:54 pm

Thanks a lot. But I really didn't get you. Can you show me in steps because i am complete n00b in Linux.
JaZZyCooL
Level 1
Level 1
 
Posts: 46
Joined: Thu Dec 06, 2012 5:37 pm

Re: How to install python scripts as ROOT?

Postby xenopeek on Sun Dec 09, 2012 4:12 am

Well, I can't get much more basic than that. One shot then, for the first suggestion I gave:
1. Open your file browser.
2. Create a new directory called "bin" (without the quotes) in your home directory.
3. Log out and log in again (this activates your "bin" directory being in the path).
4. Put your script python.py in this directory.
5. Open a terminal.
6. Run:
Code: Select all
python.py

and this will start your script regardless of where you are.
Image
Linux Mint 14 Nadia / 64-bit / Cinnamon
User avatar
xenopeek
Level 20
Level 20
 
Posts: 10505
Joined: Wed Jul 06, 2011 3:58 am
Location: The Netherlands

Re: How to install python scripts as ROOT?

Postby JaZZyCooL on Sun Dec 09, 2012 4:07 pm

I got the things thanks for your advice dude. Actually the first steps you mentioned I tried and did not get and today when i started my computer I got the things that is it takes you to restart your computer to convert your bin to root.
JaZZyCooL
Level 1
Level 1
 
Posts: 46
Joined: Thu Dec 06, 2012 5:37 pm


Return to Scripts & Bash

Who is online

Users browsing this forum: No registered users and 2 guests