I think that it's a permissions problem, because in my script
我认为这是一个权限问题,因为在我的脚本中
there are some commands that need root privileges to execute
有些命令需要root权限才能执行
I added www-data
to sudoers
hoping it would solve the problem
我向sudoers添加了www-data,希望能解决问题
and did
exec("echo \"passwd\" | sudo -S ./myscript");
exec(“echo \”passwd \“| sudo -S ./myscript”);
in my php but it didn't work.
在我的PHP但它没有用。
Thanks
1 个解决方案
#1
You could use shell_exec().
你可以使用shell_exec()。
shell_exec("echo \"passwd\" | sudo -S ./myscript");
But I'm not sure if it'll work with sudo.
但我不确定它是否适用于sudo。
Also I would like to say that adding www-data to sudoers is very dangerous.
另外我想说,向sudoers添加www数据是非常危险的。
#1
You could use shell_exec().
你可以使用shell_exec()。
shell_exec("echo \"passwd\" | sudo -S ./myscript");
But I'm not sure if it'll work with sudo.
但我不确定它是否适用于sudo。
Also I would like to say that adding www-data to sudoers is very dangerous.
另外我想说,向sudoers添加www数据是非常危险的。