cgi - source command not working when used in Perl script -
consider below code:
#!/usr/bin/perl use strict; use warnings; $value="export pi = 3.14"; open(in,">>/root/.bashrc"); print in $value; close(in); `source /root/.bashrc`;
i want create env variable using perl script. i've given 777 permissions root folder .bashrc file. $value in script getting appended .bashrc when use "env " or "printenv" display env variables, cant see 1 appended .bashrc.i guess source command not working, because when source .bashrc file cl showing in env list.please me out or suggest way.thanks in advance.
the backticks start subshell process source executed. , subshell exit , perl script not effected. have tried $env{pi}=3.14;? alter environment of running perl script , afterwards created subprocesses.
use strict ; use warnings ; $env{test} = 'yo.' ; $subshelled = qx!echo \$test! ; chomp $subshelled ; printf "subshelled result: '%s'\n" , $subshelled ; $subshellenv = qx!env! ; printf "env:\n%s\n" , $subshellenv ;
will print
subshelled result: 'yo.' env: ... test=yo.
Comments
Post a Comment