A
ad
I need to make some system calls to other programs from a perl program
and those programs that are being called have some environment
variable dependencies that are set by a shell script program. So I
have to call this shell script to set up (export bunch of variables)
environment variables so that the other program that I call can run
fine.
If all possible, I am trying to avoid writing another shell program
that call the other shell program prior to my perl program since I
have lots of variable combination that my perl program can run with
and do not want to have all the variable validated with this extra
shell program so that it can call my perl program.
In the following example, I tried both "system" and "``" (backtricks)
but none of them worked.
---- Shell Program ------------
#!/bin/sh
export T1=test1
export T2=test2
export T3=test3
export T4=test4
---- End Of Shell Program -----
----- My Test Perl Program ----
#!/usr/bin/perl
use warnings;
use strict;
#system(". ./myShell.sh"); # Tried both
`. ./myShell.sh`;
print "T1 = $ENV{T1}\n"; # Prints blank
print "T2 = $ENV{T2}\n"; # Prints blank
print "T3 = $ENV{T3}\n"; # Prints blank
print "T4 = $ENV{T4}\n"; # Prints blank
----- End Of Perl Program ----
Thanks for the help and suggestions in advance.
and those programs that are being called have some environment
variable dependencies that are set by a shell script program. So I
have to call this shell script to set up (export bunch of variables)
environment variables so that the other program that I call can run
fine.
If all possible, I am trying to avoid writing another shell program
that call the other shell program prior to my perl program since I
have lots of variable combination that my perl program can run with
and do not want to have all the variable validated with this extra
shell program so that it can call my perl program.
In the following example, I tried both "system" and "``" (backtricks)
but none of them worked.
---- Shell Program ------------
#!/bin/sh
export T1=test1
export T2=test2
export T3=test3
export T4=test4
---- End Of Shell Program -----
----- My Test Perl Program ----
#!/usr/bin/perl
use warnings;
use strict;
#system(". ./myShell.sh"); # Tried both
`. ./myShell.sh`;
print "T1 = $ENV{T1}\n"; # Prints blank
print "T2 = $ENV{T2}\n"; # Prints blank
print "T3 = $ENV{T3}\n"; # Prints blank
print "T4 = $ENV{T4}\n"; # Prints blank
----- End Of Perl Program ----
Thanks for the help and suggestions in advance.