PHP exec() command: how to specify working directory?
Either you change to that directory within the exec command (exec("cd Scripts && ./script.sh")
) or you change the working directory of the PHP process using chdir()
.
The current working directory is the same as the PHP script's current working directory.
Simply use chdir()
to change the working directory before you exec()
.