I tried out following code
/bin/sh
cd /usr
ls -al |more
on running, the first command /bin/sh forked another shell and waited for
commands. didn't execute the next commands from the script.
But when exited this child shell, the next commands i.e. cd /usr and ls -al
|more are executed.
Now if you press ctrl - D, it exits the script and returns to parent shell
and doesn't remain in /usr
So the directory change does not reflect when u finish off with the shell
script if you use command ./<shell script>
instead use . ./<shell script> to reflect the changes in shell script to
parent child
I hope I am right !
Mandar
Rohit wrote:
> "Lakshmi B. G." wrote:
> > I have created a small file called l.txt which has simple 2 statements
> > /bin/sh
> > cd /usr/local
> > tho' it creates a bash shell it does not go to the specified directory.
> > what could be the problem
>
> It could be this?
>
> You are running a shell and call this file.
> First instruction from parent shell is to fork another shell.
> So long as this child shell is existent, the parent command-2 will not
> execute.
> So, if you press control-D and exit from child shell, it will cd to that
> directory..
>
> Am I right?
> Rohit
>
> -----------------------------------------------------------------------
> Check out the 'What to do before posting to the list' site
> for a list of things to try before posting. The site is
> at http://botsie.tripod.com/beforeposting/
--
Mandar Prabhakar Behere
Member of Technical Staff
Persistent Systems Pvt. Ltd.
Phone :
office : 91-20-5676700 ext. 541
residence : 91-20-4485174
Homepage: http://www.pspl.co.in/~mandarb
-----------------------------------------------------------------------
For information on this and other Linux India mailing lists check out
http://lists.linux-india.org/