Your method will not work.
What you do in exeCD is to create a new process to do
CD command. This CD command will only affect the new
process and will not affect the process you program
runs.
You can solve this problem through a easy way. When
user type cd XXX, store the new directory in your
object. When user type ls, then list all the files in
that directory. you need not to change your program's
running directory physically.