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

apache - Remove .php and add trailing slash in url using htaccess not loading css -

inno setup - TLabel or TNewStaticText - change .Font.Style on Focus like Cursor changes with .Cursor -