我有一个基本的PHP脚本是这样的:PHP系统(“触摸...”) - 没有这样的文件或目录
<?php
system("/bin/touch /root/testfile");
当我运行命令行这个PHP脚本:
# php myscript.php
我得到这个:
sh: /touch: No such file or directory
此外,触摸是在正确的地方:
# which touch
/bin/touch
有什么我需要在我的PHP脚本中设置有关路径?因为它找不到触摸(尽管我专门用绝对路径调用它)。
UPDATE
在命令行中运行/bin/touch /root/testfile
工作正常预期。
此外,touch
不起作用,是的,但其他的东西不能正常工作,如sendmail
。我只是简单地使用touch
作为示例来解决这个问题。
如果您交互式运行'/ bin/touch/root/testfile'命令会发生什么? – Levon
为什么不使用[PHP touch](http://us3.php.net/touch) – ManseUK
'system(“/ bin/pwd”)的输出是什么;'?如果它是一个类似的错误,那么你可能已经打开了safe_mode。 – ghoti