You have been already told to use %ENV to work with these variables. Try something like this:
if (fork == 0) { # create a subprocess $ENV{myvariablename} = "desired variable value"; # set the variable ... exec("/path/to/program","some","program","arguments"); # run the program }
If you need to write shell commands, just run a shell and write your shell commands into it:
Or use multi-line system(), for example, with here-doc:open my $shell, "|/bin/sh" || die "$!\n"; print $shell "export var=value\n"; ... print $shell "some complicated shell command # ;(){:|:&};:\n"; print $shell "/run/the/program --with-args\n";
system <<"END"; export var=value ... some() {shell commands} /run/some/program END
In reply to Re: I need to export variable as another user
by aitap
in thread I need to export variable as another user
by rahulruns
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |