Re: [請益] exec執行系統命令
※ 引述《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
→
10/18 17:16, , 1F
10/18 17:16, 1F
※ 編輯: antontw 來自: 202.132.72.186 (10/18 17:18)
討論串 (同標題文章)
PHP 近期熱門文章
PTT數位生活區 即時熱門文章