in reply to What does chdir ?

Hi pcouderc,

How does the program "fail"? Is it just that you're not seeing output? The difference between the two samples you showed is that backticks capture the output of the program, which you are not doing anything with. So, probably system is better (I wrote at length about the two, their problems, and possible alternatives here), also, you should add some error checking. The following works for me:

#!/usr/bin/env perl use warnings; use strict; chdir 'core/efl' or die "failed to chdir: $!"; system('./autogen.sh')==0 or die "system failed, \$?=$?";

Hope this helps,
-- Hauke D

Replies are listed 'Best First'.
Re^2: What does chdir ?
by pcouderc (Monk) on Feb 16, 2017 at 09:34 UTC
    Thank you, you are right. Using :
    print `./autogen.sh';
    shows the correct output. So you are right : it does not fail !!
    And I shall use error checkong as you indicate. Thank you again.
      Note that once Perl exits, you will no longer be in 'core/efl'. Perl's chdir does not move the directory of the parent that started Perl. You can eliminate the chdir and combine the chdir path into the system command's path to autogen.sh with a very similar result.