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 here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Command not working preethgideon UNIX for Dummies Questions & Answers 3 05-14-2008 08:56 AM
why is this command not working? wrapster UNIX for Advanced & Expert Users 1 05-02-2008 06:11 AM
Sed command not working shashi_kiran_v UNIX for Dummies Questions & Answers 9 11-14-2006 09:01 PM
cp command not working groundlevel UNIX for Dummies Questions & Answers 7 03-22-2006 10:48 AM
last command not working antalexi SUN Solaris 3 08-04-2005 07:22 AM

Reply
 
Submit Tools LinkBack Thread Tools Search this Thread Display Modes
  #1  
Old 07-01-2006
Registered User
 

Join Date: Feb 2006
Posts: 52
cd command not working

Hello,

I am facing a strange problem while writing a script in ksh ....
though the script is too long but whenever i try to change the path to new path , the path is not changed...
like the path is :

?pwd
/osp/linus

?more script
echo "hello"
cd /osp
echo "bye"

?sh script
hello
bye

? pwd
/osp/linus

I tried all possible reasons , I am able to change via using a simple cd command but not via using it in a script........

Pls suggest what can be the possible reasons....

thanks in advance.....

Aparna
Reply With Quote
Forum Sponsor
  #2  
Old 07-01-2006
vgersh99's Avatar
Moderator
 

Join Date: Feb 2005
Location: Boston, MA
Posts: 3,016
Code:
. script
Reply With Quote
  #3  
Old 07-01-2006
Registered User
 

Join Date: Feb 2006
Posts: 52
Hello

Pls specify what is .script .......

i tried to execute the script by that but is not working.......

Pls advice and elaborate...

Thks again....
Aparna
Reply With Quote
  #4  
Old 07-01-2006
vgersh99's Avatar
Moderator
 

Join Date: Feb 2005
Location: Boston, MA
Posts: 3,016
Quote:
Originally Posted by er_aparna
Pls specify what is .script .......

i tried to execute the script by that but is not working.......

Pls advice and elaborate...

Thks again....
Aparna
'script' is the name of your script [no pun] from your original post:
Code:
?more script
echo "hello"
cd /osp
echo "bye"
There's a space between '.' and 'script':
Code:
. script
Reply With Quote
  #5  
Old 07-02-2006
LivinFree's Avatar
Goober Extraordinaire
 

Join Date: Jul 2001
Location: Portland, OR, USA
Posts: 1,584
Some shells may require that "." is in your PATH, so you may need to do
Code:
. ./script
Reply With Quote
  #6  
Old 07-03-2006
Registered User
 

Join Date: Feb 2006
Posts: 52
Hi

Thanks it worked but I am curiuos to know why it happened ? i mean why i didnt worked with sh and wirked with bot .script and . ./script.....

what is reason for this behaviour...

Thks again
Aparna
Reply With Quote
  #7  
Old 07-03-2006
linuxpenguin's Avatar
Registered User
 

Join Date: May 2002
Location: India
Posts: 295
The first . means execute in the current shell. The second ./ means execute the binary present in the present working directory.
Sometimes your PATH variable has your present directory preceeded by other directories in which case you dont need the ./
eun echo $PATH and then you can decide whether you want to use a ./ or not.
__________________
War doesnt determine who is right, it determines who is left
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes




All times are GMT -7. The time now is 11:28 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008. All Rights Reserved.Ad Management by RedTyger Visit The Complex Event Processing Blog

Content Relevant URLs by vBSEO 3.2.0