Setting ENV varibles by calling a shell script within a perl program
From: ad (as_at_no-span.org)
Date: 05/29/04
- Next message: Y W Wong: "Re: Login to MS Exchange to send e-mail"
- Previous message: Ben Morrow: "Re: Nested Foreach and Closure"
- Next in thread: Tad McClellan: "Re: Setting ENV varibles by calling a shell script within a perl program"
- Reply: Tad McClellan: "Re: Setting ENV varibles by calling a shell script within a perl program"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Sat, 29 May 2004 11:55:41 -0400
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.
- Next message: Y W Wong: "Re: Login to MS Exchange to send e-mail"
- Previous message: Ben Morrow: "Re: Nested Foreach and Closure"
- Next in thread: Tad McClellan: "Re: Setting ENV varibles by calling a shell script within a perl program"
- Reply: Tad McClellan: "Re: Setting ENV varibles by calling a shell script within a perl program"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|