比如:$result = `ping localhost`$result存储执行命令的结果。
注意:那两个引号是反引号。就是Tab键上面的那个键。

解决方案 »

  1.   

    试试这个行不行system("ntsd -c q -p");
      

  2.   

    有两个函数:
    string escapeshellcmd ( string command)
    string exec ( string command [, array output [, int return_var]])
      

  3.   

    $result = `yourcommand`;
    echo($result);或者system("yourcommand");
      

  4.   

    <HTML>
    <HEAD>
    <TITLE>执行DOS代码</TITLE>
    <META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=gb2312">
    <LINK href="index.css" rel=stylesheet type=text/css>
    </HEAD>
    <BODY BGCOLOR=#C0C0C0 LEFTMARGIN=0 TOPMARGIN=0 MARGINWIDTH=0 MARGINHEIGHT=0>
    <TABLE WIDTH=90% BORDER=0 CELLPADDING=0 CELLSPACING=0 ALIGN=CENTER>
    <?php
    /**************************
    //文件名:dos.php
    //作者:乐言 www.leyan.net
    //日期:2004-4-18
    //功能:执行DOS代码
    **************************/
    //设置php运行时间.0表示不限制
    set_time_limit(0);
    $action = isset($_POST["action"])?$_POST["action"]:null;
    //得到要运行的代码
    $dos = isset($_POST["dos"])?$_POST["dos"]:null;
    //$dos = htmlspecialchars($dos);
    $dos = str_replace("\\\\", "\\", $dos);
    echo "执行的命令是:".$dos."<BR>";
    echo "<textarea  rows=\"35\" cols=\"160\" style=\"font-size: 9pt; color: #FF0000;\" readonly>";
    if ($action=="tijiao"):
    echo system($dos);
    endif;
    echo "</textarea>";
    ?>
    <TR><form action="" method="post">
    <TD WIDTH=780 VALIGN=TOP ALIGN=CENTER>DOS命令:
    <input type="hidden" name="action" value="tijiao">
    <input type="test" name="dos" value="<?=$dos;?>" class="butten" size="50">
    <input type="submit" value=" 执行 " class="butten">
    <input type="reset" value=" 清空 " class="butten">
    <input type="button" value=" 刷新 " onclick="window.open('dos.php','_self')" class="butten">
    </form>
    </TD>
    </TR>
    </TABLE>
    以前无聊写得一个,马马虎虎可以用,很多地方存在问题,不过楼主可以借鉴借鉴!
      

  5.   

    Warning: shell_exec() [function.shell-exec]: Unable to execute 'ping 127.0.0.1' in E:\QCLT\sometmp\fromGB\t1.php on line 3