Best way to execute a script ?
There are many ways to execute a script (*.sh). But what is the best way to execute a script also what should be its location. So that it can be executed from anywhere in the shell. I don't want to execute them with ./*.sh.
thanks in advance |
I put them in
Code:
/usr/local/bin |
thanks for ur answer
if I create a folder in /usr/local/bin/ and put all scripts in that folder. is it ok or not. |
no, just put them in
/usr/local/bin If you create a folder, you need to add the folder to your PATH /usr/local/bin is already in your PATH |
thanks
|
I myself have my script in a /home/user/script_folder since 2 different users have there own personnel backup script on the main computer it is more convenient.
|
thanks Davno
can you please describe, how to make them executable like other commands if I copy scripts in /home/ssvirdi/myScripts. |
"Where" to put them is one question. You can put them anywhere as long as the location is included in your $PATH, to see the current value of $PATH just use this:
Code:
$ echo $PATH "How" to modify your $PATH to include any arbitrary location is an entirely different question, and that depends on the shell you use. Most of them will read /etc/profile, per-user settings are defined in each shell init files, for bash that can be ~/.bash_login, ~/.bashrc or ~/.bash_profile depending on what do you exactly want to do. Other shells will use different config files, so, check your $SHELL man/info page or documentation. |
Quote:
PATH="$PATH":/home/ssvirdi/myScripts . |
All times are GMT -5. The time now is 09:10 AM. |