Shell scripting basic doubt


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Shell scripting basic doubt
# 1  
Old 08-04-2006
Shell scripting basic doubt

Hi,
I have a script called sam.sh which consists of a single echo statement like this

#/usr/bin/ksh
echo "Mani"

I changed the mode for the script by giving chmod a+x sam.sh.

If I want to execute the scrpt by just giving the name at the command line "sam.sh", what should I necessarily do? I dont want to execute the script as ./sam.sh

Thanks in advance
# 2  
Old 08-04-2006
Code:
ksh sam.sh

and for this you don't need to do chmod
or
Code:
sam.sh

# 3  
Old 08-04-2006
Add sam.sh to one of the directories listed in your path settings.

echo $PATH will give the list fo directories
# 4  
Old 08-04-2006
The solutions above will only work if the directory containing the script is in your path - the reason you have to type ./sam.sh is to specify the that the script is in your current working directory (.).

You could change your path to include the directory containing the script (your home directory?) or the current directory (.) or, better, create an alias, e.g.

Code:
alias sam.sh=<absolute directory path>/sam.sh

Note that this needs to be an absolute path starting with a slash (like /home/mine) not relative to the current working directory (like ./mine) so that it will work whichever directory is current.

Put this in your login file (.profile, .bash_profile, .cshrc or whatever it is for your system) to make it available each time you log in.

cheers
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Basic Shell Scripting

Hi All, I am a newbie to shell scripting. I am trying to something like this. #!bin/bash cd /u01/app/oracle/ # then start the process ./opmnctl startall Can someone help me with this requirement. Help is very much appreciated. Thanks Venkat Please use code tags next time for... (10 Replies)
Discussion started by: venkat8439
10 Replies

2. Shell Programming and Scripting

Help related to clearing of shell scripting doubt

Hello Gurus, Can anybody please help me to understand as what does this lines(Marked in bold) does: _TABLESPACE_OFFLINE=`cat ${_tmp_res} | grep -iv "online" | grep -v "^*$" | grep -iv "SQL>"` ------->1 if ;then _tmp_tablespace_status=1 ... (1 Reply)
Discussion started by: hitesh1907
1 Replies

3. Shell Programming and Scripting

Shell scripting Variable doubt

Dear Friends, If i give the command echo $- i am getting output of himBH. Can some body explain what does it means echo $- himBH Thanks in Advance Rajkumar (2 Replies)
Discussion started by: rajkumarin
2 Replies

4. Shell Programming and Scripting

Bash shell scripting doubt

Hello All, I am setting up a cron job, where i am calling a shell script to make few builds. I got struck at a point, need some expert inputs to proceed further. The script is categorized in 5 parts and in the last part while building software it asks for few questions like:- 1. Build mode... (4 Replies)
Discussion started by: sahil_jammu
4 Replies

5. Shell Programming and Scripting

which is the Very basic certification on unix shell scripting?

Hi, I am very new to this forum, can any one tell me which is the very basic certification on unix shell scripting? please give me an advice on this. (1 Reply)
Discussion started by: Manjesh
1 Replies

6. Shell Programming and Scripting

shell script basic doubt

hi, I am new script learner, so my basic doubt is , how to store value of any command in a variable example $ ls | wc -l i want to stote the output of this in a variable c. so that i can use c in if else loop. and when do we use " ` " symbol in script.. can anyone also tell for... (5 Replies)
Discussion started by: hi2_t
5 Replies

7. Shell Programming and Scripting

basic shell scripting question

If I did indeed grep something out of it, why woudln't $result show nothing? When I do $? , it does show success... What is the proper syntax so that $result shows actual thing it's grepping out? result=`(ssh $host tail -1 /something/somethingelse) | egrep -i "value" >dev/null` #echo... (3 Replies)
Discussion started by: convenientstore
3 Replies

8. Shell Programming and Scripting

Certainly basic doubt about IF

On the below "IF" i test if the user have put the first argument. I also would like to test if the user have written a second argument. So, my doubt is: - How can i evaluate 2 conditions on a if statement? How is the OR created? - How can i to verify if the second argument is non... (1 Reply)
Discussion started by: tmxps
1 Replies

9. Shell Programming and Scripting

What is a good place to learn basic shell scripting? Thanks!

See the title. Originally wasn't going to type anything but I need a message of at least 10 characters! :cool: (2 Replies)
Discussion started by: deutchap6verse5
2 Replies
Login or Register to Ask a Question