Q:

Changing the current directory using a script (ksh)

I'm launching my script from echo $PWD ---> /x. I want my script to change my current directory.
So my script contains +- this :
cd /y
exit 0

However, when my script ends, I'm stils in echo $PWD ---> /x. I'd like to be in /y.
Why doesn't it work ? 
I'm launching my script simply by doing : [myScriptName]

A:

That's because your shell starts another shell to run your script. The second shell changes its working directory and then exits to the first shell, which never changed its directory.
To make your current shell run the script, call it this way:
. scriptname

(notice the dot). Of course, you'll have to take out that exit 0.
You can also write a shell function. See ksh(1).

