Loading ...
Sorry, an error occurred while loading the content.

[PBML] Re: Moving between directories

Expand Messages
  • Jeff Eggen
    ... ... But, if you expect the Perl script to change your directory for your current shell session, you re going to have to try something different. The
    Message 1 of 1 , Jun 30, 2003
    • 0 Attachment
      >>> daymobrew@... 06/30/03 02:25am >>>
      >> Could anyone tell me how I could move between the directories ( or
      >> change the present working directory ) with any perl command ??
      <snip>
      >> After I execute the perl code, the PWD still remains unchanged.


      >chdir( $ENV{'HOME'} );

      >This is a perfect example (albiet unusually unique) where using
      >external programs when an equivalent perl function exists is bad.

      But, if you expect the Perl script to change your directory for your
      current shell session, you're going to have to try something different.
      The chdir command will change the working directory, but your Perl
      script is a separate process from your shell session, and so your shell
      session is oblivious to whatever it's doing. There may be a way to do
      it in Perl, but I don't know it: to the best of my knowledge, you have
      to rely on the shell. You could make a small shell script that wraps
      around your Perl code, and then source the wrapper to execute the Perl
      code and end up in a new directory.

      Hope this helps
    Your message has been successfully submitted and would be delivered to recipients shortly.