The UNIX and Linux Forums  


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.

Reply
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 07-22-2009
TimHortons TimHortons is offline
Registered User
  
 

Join Date: Nov 2008
Posts: 53
Help with why I need to use ./

I use to be able to do a . test.sh shell script but now I have to do ./test.sh

Can someone explain what has most likely happen to cause this.

thank you
  #2 (permalink)  
Old 07-22-2009
scottn scottn is offline Forum Advisor  
VIP Member
  
 

Join Date: Jun 2009
Location: Zürich, CH
Posts: 1,113
Most likely is that the directory you are running test.sh from is not in the PATH
  #3 (permalink)  
Old 07-23-2009
vino's Avatar
vino vino is offline Forum Staff  
Supporter (in vino veritas)
  
 

Join Date: Feb 2005
Location: Bangalore, India
Posts: 2,798
You could be missing a . in the PATH variable. A . denotes the current directory.
  #4 (permalink)  
Old 07-23-2009
basher basher is offline
Registered User
  
 

Join Date: Jun 2009
Posts: 2
Don't confuse . (source the script) with ./ (Under the current directory)

. test.sh = source test.sh

Now the shell looks for the directories in the path ($PATH). If it finds test.sh in any of those directories it will execute or you would have to go to that directory and do a ./test.sh
To avoid doing a ./ do the following.
Edit your .bash_profile or .bashrc file under your home directory.
add the line
export PATH='$PATH:.' -> i.e. add a . to the end of the path

If this doesn't work for you change the single quotes to double quotes.
Run echo $PATH to check if the path is correct.
Reply

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 01:17 AM.


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