Re: system ("cd ..")



Hi,
How can I access a specific child process, such that I put all my system commands in one child process?


Thanks alot
Eliyah


Bob Showalter wrote:

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: IPC
    ... >> This is a nasty command that attempts to fill up your disk with a file ... because the shell process will wait for the command process ... parent shell will NOT wait for the child process to complete. ... child process 22187 finished, closing pipe ...
    (comp.lang.perl.misc)
  • Re: Spawning process with environment variables
    ... process exits parent process exits too. ... The simple way to solve this is to call fork before. ... read its exit return code (what child process' main returns) ... If you don't mind a shell running the command for you simply use ...
    (comp.unix.programmer)
  • Re: C++ on Unix - serious coding help needed. Were in the Silicon valley location
    ... it's not possible for a child process to ... his 'hm' command a curiosity, ... and object code area separate, ... There are also a few other technical problems with his, ...
    (comp.os.linux.misc)
  • Re: C++ on Unix - serious coding help needed. Were in the Silicon valley location
    ... it's not possible for a child process to ... his 'hm' command a curiosity, ... and object code area separate, ... There are also a few other technical problems with his, ...
    (comp.os.linux.development.apps)
  • Re: IPC
    ... You want to use the system command here ... ... Pid in perl script are different from Pid in bash and so I can't kill them and I can't wait for them. ... 19992 pts/1 00:00:00 example.pl ... 20001 pts/1 00:00:00 sh child process 19993 finished, ...
    (comp.lang.perl.misc)