如何使用php执行cmd命令 比如:$result = `ping localhost`$result存储执行命令的结果。注意:那两个引号是反引号。就是Tab键上面的那个键。 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 试试这个行不行system("ntsd -c q -p"); 有两个函数:string escapeshellcmd ( string command)string exec ( string command [, array output [, int return_var]]) $result = `yourcommand`;echo($result);或者system("yourcommand"); <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>以前无聊写得一个,马马虎虎可以用,很多地方存在问题,不过楼主可以借鉴借鉴! Warning: shell_exec() [function.shell-exec]: Unable to execute 'ping 127.0.0.1' in E:\QCLT\sometmp\fromGB\t1.php on line 3 如何获得抓取的页面中的href和text 如何下载华夏大地自考教育网中的网络视频? 哪个在线编辑器可以直接word粘帖公式呀 数据库插入时的问题。 mysql updata问题请教 PHP菜鸟,怎样通过cookie检测用户是否在线 新手学PHP,第一个测试MYSQL的PHP文件就出错,大侠帮忙看看,很简单的. 有关php的安装,急!急!急!!!!!!! 初学碰到问题请帮我 ecshop,wstmart和iwebshop,开源商城系统怎么选择 如何在自己的网站上实现flash 控件(OCX) 下载.. 如何让一个用window.open方法打开的窗口显示在屏幕中央?
string escapeshellcmd ( string command)
string exec ( string command [, array output [, int return_var]])
echo($result);或者system("yourcommand");
<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>
以前无聊写得一个,马马虎虎可以用,很多地方存在问题,不过楼主可以借鉴借鉴!