linux - Directory not changing using exec comman in php -


hi trying make use of exec command , change directory execute specific command, change directory not working

when execute exec('whoami'); proper output 

when execute following code

<?php  ini_set('error_reporting', e_all); $var =  exec('cd /root/'); echo exec("pwd");  ?> 

my directory not changing root

i think need use chdir() rather exec('cd /root/'):

<?php  ini_set('error_reporting', e_all); $var = chdir('/root/'); echo exec('pwd'); // prints /root 

this may not work if running on website , user http server running not have access /root.

the reason exec() doesn't work opens new subprocess each time. changing current directory in 1 not affect others spawned after.


Comments

Popular posts from this blog

hibernate - How to load global settings frequently used in application in Java -

python 3.x - Mapping specific letters onto a list of words -

objective c - Ownership modifiers with manual reference counting -