The solution I proposed works - and I tested it. #!/bin/perl -w $ENV{MY_ENVIRONMENT_VARIABLE} = "Quixotic Response"; system("env");
However, this is Perl - TMTOWTDI! If you want to undo the setting after running the shell, either localize %ENV or delete the new variable. { local(%ENV) = %ENV; $ENV{MY_ENVIRONMENT_VARIABLE} = "Quixotic Response"; system("env"); } or #!/bin/perl -w $ENV{MY_ENVIRONMENT_VARIABLE} = "Quixotic Response"; system("env"); delete $ENV{MY_ENVIRONMENT_VARIABLE}; Ron's solution won't work unless you are running a sane shell (C shell doesn't like export, a true Bourne shell doesn't like export with the assignment!). And, if you're using a sane shell, you don't need the export, you can simply write: system("VAR=val /path/to/your/shell/script"); Well, that worked nicely for me with Korn Shell (and would work with Bourne Shell), but won't work with C shell (again). You can have multiple environment variables set if you need to: system("VAR1=val1 VAR2=val2 /usr/bin/env"); And Scott's response arrived before I sent this but after I'd typed it. Find "Csh Programming Considered Harmful" via Google if you don't understand why C shell is not a good idea. On 1/19/07, Reidy, Ron <[EMAIL PROTECTED]> wrote:
Short answer - you cannot (sort of). This is because your shell script will execute in a sub shell of your perl program. However, you can do something like this: # untested system("export VAR=val; /path/to/your/shell/script.sh"); I think that might work for you. -- Ron Reidy Lead DBA Array BioPharma, Inc. -----Original Message----- From: Oscar Gomez [mailto:[EMAIL PROTECTED] Sent: Wednesday, January 17, 2007 8:59 AM To: dbi-users@perl.org Subject: environment variable how can i export a variable from program perl to shell script through environment variable. Thank you -- Open WebMail Project (http://openwebmail.org) This electronic message transmission is a PRIVATE communication which contains information which may be confidential or privileged. The information is intended to be for the use of the individual or entity named above. If you are not the intended recipient, please be aware that any disclosure, copying, distribution or use of the contents of this information is prohibited. Please notify the sender of the delivery error by replying to this message, or notify us by telephone (877-633-2436, ext. 0), and then delete it from your system.
-- Jonathan Leffler <[EMAIL PROTECTED]> #include <disclaimer.h> Guardian of DBD::Informix - v2005.02 - http://dbi.perl.org "I don't suffer from insanity - I enjoy every minute of it."