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

Use chdir() to change directories

Alan "Hot Pastrami" Bellows
  • Comment on Re: How do I change directories from within a script?

Replies are listed 'Best First'.
Re: Re: How do I change directories from within a script?
by Splatt (Initiate) on Dec 14, 2000 at 01:52 UTC
    Ah...! Thanks! Learning a new language can be terribly embarassing at times! :)

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

      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.