The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Basic Linux Shell Scripting for Oracle DBAs iBot Oracle Updates (RSS) 0 04-06-2008 05:10 AM
got a basic doubt on cat-file permissions ranj@chn UNIX for Dummies Questions & Answers 7 08-23-2007 05:39 AM
basic shell scripting question convenientstore Shell Programming and Scripting 3 05-27-2007 10:21 PM
Certainly basic doubt about IF tmxps Shell Programming and Scripting 1 10-31-2005 04:53 AM
What is a good place to learn basic shell scripting? Thanks! deutchap6verse5 Shell Programming and Scripting 2 03-08-2005 02:55 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 08-04-2006
sendhilmani123 sendhilmani123 is offline
Registered User
  
 

Join Date: Apr 2006
Posts: 33
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 (permalink)  
Old 08-04-2006
Dhruva's Avatar
Dhruva Dhruva is offline
Registered User
  
 

Join Date: Mar 2006
Location: India
Posts: 255
Code:
ksh sam.sh
and for this you don't need to do chmod
or
Code:
sam.sh
  #3 (permalink)  
Old 08-04-2006
vish_indian vish_indian is offline
Registered User
  
 

Join Date: Jun 2006
Location: Delhi, India
Posts: 92
Add sam.sh to one of the directories listed in your path settings.

echo $PATH will give the list fo directories
  #4 (permalink)  
Old 08-04-2006
thestevew thestevew is offline
Registered User
  
 

Join Date: Mar 2006
Location: South Yorkshire, UK
Posts: 114
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
Sponsored Links
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 07:35 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0