![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum Rules | FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| UNIX for Advanced & Expert Users Advanced UNIX and Linux questions go here. Expert-to-Expert. |
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| problem in tar command | sais | UNIX for Dummies Questions & Answers | 1 | 05-12-2008 08:20 AM |
| Problem with tr command a-z 0-9 | kodermanna | UNIX for Advanced & Expert Users | 1 | 04-12-2008 01:32 AM |
| problem with tr command | ravi raj kumar | UNIX for Advanced & Expert Users | 2 | 07-02-2007 03:41 AM |
| problem with dd command or maybe AFS problem | Anta | Shell Programming and Scripting | 0 | 08-25-2006 07:10 AM |
| Problem with cut command | amon | Shell Programming and Scripting | 7 | 02-15-2006 08:22 AM |
|
|
Submit Tools | LinkBack | Thread Tools | Display Modes |
|
#1
|
||||
|
||||
|
hello guys,,
here is my problemia have written a code as below var="vi" if [ "$var" = "vi" ] ; then cd <some path> echo $PWD fi my problem is after exicution of this code the cintrol will return to the path from where its exicuted but how can i modify so this so that after exicution of this script the control will go to cd <some path> i mean suppose first /home/vidy> after /home/vidya/fns/pd/r> is it possible??? suggest some answer!!!! |
| Forum Sponsor | ||
|
|
|
#2
|
|||
|
|||
|
This problem you're having is due to inheritance. When you run/execute your script, it inherits a copy of the current environment. Anything you do in the script affects your inherited environment but not that of your parent.
What you need to do is source your script instead of running it. When you source it, it runs under your current shell so changes that you make will be reflected in your environment when the script finishes executing. Assuming your script is named test.sh, and you're in the directory where the script resides, source it as follows: > . ./test.sh If you do this, when execution is complete, you will be in whatever directory was specified by the "cd <some path>" command. |
|
#3
|
||||
|
||||
|
thanku very much this helped a lot.
|
||||
| Google The UNIX and Linux Forums |