The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
Google UNIX.COM


UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !!

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
running script in any directory shinjeck SUN Solaris 1 10-26-2007 02:23 AM
Calling a script from any directory ketanr Shell Programming and Scripting 1 10-17-2007 01:16 PM
Change Directory via a script? George Borrmann Shell Programming and Scripting 3 10-09-2006 05:13 PM
Changing directory through script mrgubbala UNIX for Dummies Questions & Answers 5 02-11-2005 07:12 AM
Using ls in a script for another directory jagannatha UNIX for Dummies Questions & Answers 17 06-05-2003 03:52 PM

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

Join Date: Jul 2006
Posts: 49
script for chainging the directory

#!/bin/sh

echo "Enter the Num"
read $i
cd /aa/$i/abc

when i execute the above i am getting the error
where $i=205

another point is i have just place
#!/bin/sh
cd /aa/205/abc

when i execute this i am unable to change the directory...

but i am able to login by
/home/cvs cd /aa/205/abc
here i am able to change the directory..
/aa/205/abc


Any inof on this...
Reply With Quote
Forum Sponsor
  #2  
Old 09-15-2006
...@...
 

Join Date: Feb 2004
Location: NM
Posts: 4,298
In reverse order:

When you change directories in a child process, when the child process exits, the parent proces (the one that called the script) is where it started. No change.
Code:
. myscript.sh
Notice the DOT spec before the script name. This is called sourcing.
It makes the process run in the parent, not a child. So, if the script changes directories it will "stick" in the parent process.
The first question
Code:
echo "enter something \c"
read i  # notice NO $ in front of i
echo "$i"    # now we need a $
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 04:22 AM.


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