RE: system ("cd ..")



Eliyah Kilada wrote:
> Hi,
> It seems that the following code gives unexpected results:
>
> system ("cd $dir_name");
> system ("pwd");
> ---> this prints the old directory name not the new one. In other
> words, the previous (cd) command hasn't taken its effect!
> Do anyone know why?

Each call to system() creates a separate process in which the command is
executed. The cd command only affects that separate process.

You need to use Perl's chdir() function to change the working directory for
the current process.
.



Relevant Pages

  • Re: Mathematica, Axiom or Maxima?
    ... Showing "human steps" is an almost entirely separate process. ... but that's what is actually needed for teaching Calculus. ...
    (sci.math.symbolic)
  • Re: Need to break a string "Hello1 Hello2 Hello3 Hello4 ..." into an array (of words) in Bash, any h
    ... into an array of elements. ... The command returns a string with all the filenames concatenated. ... is that the while loop will execute in a separate process, ...
    (comp.unix.programmer)
  • Console.WriteLine() problem
    ... if there are no command line arguments then go ahead and display the ... another application from a separate process. ... when I run it from a command prompt it will display the information at ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: trouble installing WMP11
    ... Prev version system is ... Setup version 10.00.00.3646.] ... ERROR: WMC_CopyFile: Could not find source file ... Current command line: '/UpdateWMP'. ...
    (microsoft.public.windowsmedia.player)
  • Using Select Case to evaulate a new field entry
    ... >it work by using a command button, ... >automatically update after changes to the base fields. ... Prev by Date: ...
    (microsoft.public.access.modulesdaovba)