"export" linux command not working

I want to execute some unix command from php script. The code is below.

$filepath='/home/biplab/hft'; $folder='0b'; exec('export HFT_BASEDIR='.$filepath); chdir($file_path.'/'.$folder); exec('make prod'); 

Now the problem is that exec('export HFT_BASEDIR='.$filepath); doesn’t work, so many errors are displayed ... Is there an alternative for executing the same command.

please help me as soon as possible .. thanks in advance

+4
source share
2 answers

It works great. But the shell that you execute dies before the function is called. Try putenv() .

+1
source

environment variables are local to processes; export only tells the shell to pass these variables to child processes.

 exec('export HFT_BASEDIR='.$filepath . '; make prod'); 
+1
source

All Articles