作者antontw (习惯)
看板PHP
标题Re: [请益] exec执行系统命令
时间Wed Oct 18 17:15:03 2006
※ 引述《wshadow (小早)》之铭言:
: ※ 引述《wshadow (小早)》之铭言:
: : apache的使用者是www
: : 我用www登入後执行/usr/local/bin/php makesh.php
: : 可以成功执行makesh.php,印出test
: : makesh.php内容:
: : if(exec("sudo sh backnow.sh",$res,$err))
: : {
: : echo "test";
: : }
: : else echo $err;
: : 可是用网页开启makesh.php
: : 却印出127($err)
: : 请问有人知道怎麽解决吗/____\
: 用绝对路径後还是出现127.....orz
: if(exec("/usr/bin/sudo /bin/sh /home/wwwadmin/mysqlbk/mysqlbk/backnow.sh"
: ,$res,$err))
: {
: echo "test";
: }
: else echo $err;
我确定 "/usr/bin/sudo /bin/sh /home/wwwadmin/mysqlbk/mysqlbk/backnow.sh"
这样下是有用的,至少我刚刚 sh 里面下 cat /etc/shadow 都有出来,
所以要问:
1. /home/wwwadmin/mysqlbk/mysqlbk/backnow.sh <-- 这个的内容
2. /home/wwwadmin/mysqlbk/mysqlbk/backnow.sh <-- 这个的权限
另外:
the exit status is 0 if command was found, and 1 if not. If
neither option is supplied and an error occurred or command can-
not be found, the exit status is 127. Otherwise, the exit sta-
tus of the command builtin is the exit status of command.
--
人不作出牺牲,便得不到任何收获;如果要得到某种东西,就必须付出同等代价。这一点
,就是链金术的基本原则 ── 等价交换。当时我们深信这一点就是世界的真理。
阿尔风斯‧爱力克,《钢之链金术师》开场白
--
※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 202.132.72.186
1F:→ antontw:忘了,还有 sudo 的设定也请一并 po 出来 10/18 17:16
※ 编辑: antontw 来自: 202.132.72.186 (10/18 17:18)