LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Shorcut to sh file (https://www.linuxquestions.org/questions/linux-newbie-8/shorcut-to-sh-file-520388/)

Ejdaha 01-18-2007 01:13 AM

Shorcut to sh file
 
Hi all
I want to create a file for example with name run
And want to login to linux as root and type run and want this script do somethings..
Where I must put it??
Thanks...

Samotnik 01-18-2007 01:24 AM

Login as root and look for content of PATH variable (with echo $PATH). You'll see all the directories where shell will look for commands. Put your script in one of them.

linuxles 01-18-2007 01:46 AM

When logged in as root your home should be /root

To verify it; "echo $HOME".

Irregardless of the user that you are logged in
as, a directory called bin should exist in $HOME,
if it doesn't create it and put your executable
in there...

By default $HOME/bin is part of the directory path.

To verify it; "echo $PATH"

Then, make sure the script is set to executable.
To verify it; "ls -al <scriptname>"
You should see something like:
-rwxr--r-- 1 root root 27 Jan 01 01:01 <scriptname>
If the executable bit is not set, use "chmod" to
set it.

Now, regardless of what directory you are in while
you are logged in as root, you can just execute the
script by typing in the scriptname.

NOTE: Disregard the previous posters recommendation
to put it in any directory in the path, that is just
plain wrong...

/Les

Ejdaha 01-18-2007 01:55 AM

Thank you very very much!!!!


All times are GMT -5. The time now is 12:37 AM.