溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點擊 登錄注冊 即表示同意《億速云用戶服務條款》

php頁面?zhèn)鲄⒔oshell腳本

發(fā)布時間:2020-07-25 12:48:46 來源:網(wǎng)絡 閱讀:3851 作者:290480358 欄目:web開發(fā)

代碼如下:

<html>

<head>

<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />

<title>MAC search</title>

</head>

<body align="middle" bgcolor="gray">

<h2><font size="20" face="Verdana" color="blue">MAC search</font></h2>

<form action="" method="post">

MAC:

<input type="text" name="mac" size="20"/>

<input type="submit" value="submit"/>

</form>

<?php

if(isset($_POST['mac'])&&$_POST['mac']!=''){

        $mac=$_POST['mac'];

$output = shell_exec("macsearch $mac");

echo "$output";

}

?>

</body>

</html>

分析如下:

    1.通過表單傳入一個參數(shù)“mac”        

        <form action="" method="post">

        MAC:

        <input type="text" name="mac" size="20"/>

        <input type="submit" value="submit"/>

        </form>

    2.通過php傳入?yún)?shù)并且運行shell腳本     

        <?php

        if(isset($_POST['mac'])&&$_POST['mac']!=''){

                $mac=$_POST['mac'];

        $output = shell_exec("macsearch $mac");

        echo "$output";

        }

        ?>


補充:今天遇到一個問題,通過php頁面執(zhí)行這個腳本的時候無效,macsearch腳本中的wget命令未執(zhí)行(macsearch腳本在博文《字符串按位數(shù)分隔》中有)

    1.切換到一個普通用戶執(zhí)行macsearch發(fā)現(xiàn)也不執(zhí)行wget命令

    2.檢查目錄權限,發(fā)現(xiàn)/srv/macsearch/record權限為755,普通用戶無寫入權限,所以執(zhí)行:

        chmod -R 777 /srv/macsearch/record

    3.問題解決


向AI問一下細節(jié)

免責聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉載和分享為主,文章觀點不代表本網(wǎng)站立場,如果涉及侵權請聯(lián)系站長郵箱:is@yisu.com進行舉報,并提供相關證據(jù),一經(jīng)查實,將立刻刪除涉嫌侵權內(nèi)容。

AI