Linux Help
guides forums blogs
Home Desktops Distributions ISO Images Logos Newbies Reviews Software Support & Resources Linuxhelp Wiki

Welcome Guest ( Log In | Register )

Advanced DNS Management
New ZoneEdit. New Managment.


Sign Up Now
Reply to this topicStart new topic
> Problems With Cd In A Bash Script
post May 24 2003, 11:30 PM
Post #1

Whats this Lie-nix Thing?

Group: Members
Posts: 1
Joined: 24-May 03
Member No.: 885


I'm having problems with a bash script I wrote and have never been able to figure this part out.

Whenever I put a cd <somedir> into a bash script it will change to that dir for the duration of the script. But, when the script is done executing I'm back in the same dir I was when I executed the script.

I assume then that there is some specific command that you need to use in order to make the change stick, I just have never been able to find it.

Any help would be appreciated. Thanks!
Go to the top of the page
+Quote Post
post May 25 2003, 12:48 PM
Post #2

RMS is my Hero

Group: Support Specialist
Posts: 782
Joined: 6-October 02
From: Trichy,INDIA
Member No.: 29

because shell script u tried to run is basically a child of the main shell(bash).or to put in other words ..when u execute a shell script those command are issued to a new shell started by the when the shell script exits the change of directory is no longer valid.

so u have to run the script in the current shell and u can do it in this way:
$. ./<shell_script>

this will certainly solve ur problem

Hemant Kumar
user posted image
Go to the top of the page
+Quote Post

Reply to this topicStart new topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:


RSS Lo-Fi Version Time is now: 22nd April 2018 - 05:24 PM