in reply to Re: passing a variable from shell script to the main perl
in thread passing a variable from shell script to the main perl

Can you please elaborate on this? I am not quite following you. thx
  • Comment on Re^2: passing a variable from shell script to the main perl

Replies are listed 'Best First'.
Re^3: passing a variable from shell script to the main perl
by wind (Priest) on Apr 05, 2011 at 22:13 UTC

    How are you calling your shell script? Are you using system?

    system("shell.sh");

    Any changes that your shell.sh script makes to the %ENV will not stay after the system command is finished. Instead, simply have your shell.sh script echo some text that your perl script can capture when using backticks.

    my $results = `shell.sh`; if ($results =~ /Hello World/) { print "tada!"; }
    shell.sh
    echo "Hello world";
      <text>when I do this </test>  $xx=`sh $translationscript $filename $source_dir $file 2>&1`; <text> the value $xx has the log from the shell script and the STDOUT. Also, in the shell, I am checking for some errors and based on the error - I have a variable defined and I want that variable need in perl and then I will have to continue my script based upon the type of error I get from the shell. How do I do this? </text> thx