in reply to Re: How do I change directories from within a script?
in thread How do I change directories from within a script?

Ah...! Thanks! Learning a new language can be terribly embarassing at times! :)

There's nothing more dangerous than a resourceful idiot. --- Dilbert

  • Comment on Re: Re: How do I change directories from within a script?

Replies are listed 'Best First'.
Re: Re: Re: How do I change directories from within a script?
by Fastolfe (Vicar) on Dec 14, 2000 at 03:43 UTC
    The reason that system("cd some_dir") doesn't work is because the system call is spawning a new process (in this case a shell), so any changes made to that shell's environment (such as changing the current working directory) are lost when the sub-process exits. You end up creating a child process and sending it to a new directory, where it expectedly dies/exits of natural causes and returns control back to you. You didn't move anywhere.