Once more, there is more than one way to do it ...

Modifying %ENV, perhaps with local, seems to be the cleanest and fastest way. do { local $ENV{'FOO'}='bar'; local $ENV{'GOD'}='Larry'; system('/usr/local/bin/shellscript.sh','--do-something'); };

Fiddling with the shell in system() looks AT LEAST dangerous to me (assuming some of the environment values may come from the network). system "FOO=$bar /usr/local/bin/shellscript.sh --do-something" may look harmless, but what happens if $bar is "x rm -rf $HOME;" ?

On most Unix-like systems, there is /usr/bin/env, which does not only dump the environment, but may also modify or reset it before passing control to another program. Type man env to learn what env can to for you. Something like system('/usr/bin/env','-','FOO=bar','GOD=Larry','/usr/local/bin/shellscript.sh','--do-something') should work.

On Windows, think about porting the "shell" script to Perl.


Oh, by the way: What is the relation of this question to Perl's Database Interface?

Alexander

Oscar Gomez wrote:
how can i export a variable from program perl to shell script through environment variable.

Thank you

--
Open WebMail Project (http://openwebmail.org)

--
Alexander Foken
mailto:[EMAIL PROTECTED]  http://www.foken.de/alexander/

Reply via email to