?? exec.csp
字號:
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=gb2312">
<title>eyBuild Demo - Execute Command</title>
<link href="style.css" rel=stylesheet type=text/css>
</head>
<body onload="document.forms[0].elements[0].focus();">
<form method=post action="exec.csp">
<h3>輸入執行的命令:</h3>
[<a href="list.csp?path=<% =urlEncode(path) %>">返回到目錄列表]</a>
(當前目錄: <% =path %>)
<p>輸入命令: <input type="text" size=100 maxlength=255 name="cmd" value="<% =pcmd %>">
<input type="hidden" name="path" value="<% =path %>">
<p>最大執行時間:
<% SELECT_BEGIN("maxtime", maxtime, "") %>
<% OPTIONS_ADD("1", "1 秒鐘以內") %>
<% OPTIONS_ADD("2", "2 秒鐘以內") %>
<% OPTIONS_ADD("5", "5 秒鐘以內") %>
<% OPTIONS_ADD("10", "10 秒鐘以內") %>
<% OPTIONS_ADD("30", "30 秒鐘以內") %>
<% OPTIONS_ADD("60", "1 分鐘以內") %>
<% OPTIONS_ADD("120", "2 分鐘以內") %>
<% OPTIONS_ADD("300", "5 分鐘以內") %>
<% OPTIONS_ADD("600", "10 分鐘以內") %>
<% SELECT_END() %>
</p>
<p><input type="submit" name="submit" value="提交命令">
<input type=hidden name="sendcmd" value="true"></p>
</form>
<hr>
<b><font size=3>執行結果:</font></b>
<p>命令名: <% =pcmd %>, 最大執行時間: <% =maxtime %> 秒</p>
<xmp><%
sprintf(cmd, "%s 2>&1", pcmd); /* redirect stderr to stdout */
if (!isblankstr(pcmd) && OK == exec_cmd(cmd, path, atoi(maxtime), errmsg))
strcpy(errmsg, "命令正常結束");
%></xmp>
<HR><H3>執行狀態:</H3>
<font color="red"><% =errmsg %></font>
</body>
</html>
<% @b
@include <stdlib.h>
char path[256] = "";
char cmd[512] = "";
char errmsg[256] = "無命令執行";
char * pcmd = G("cmd");
char * maxtime = G("maxtime");
/* set default timeout */
if (atoi(maxtime) <= 0 || atoi(maxtime) > 600)
maxtime = "5";
/* reduce '.' and ".." */
BUFCPY(path, G("path"));
trimpath(path);
if (!isblankstr(G("sendcmd")))
{
if (isblankstr(pcmd))
{
strcpy(errmsg, "無命令輸入, 請輸入命令!");
}
}
%>
<% @g
#ifdef __cplusplus
extern "C" {
#endif
int exec_cmd(char *pcmd, char * curdir, int maxtime, char * errmsg);
#ifdef __cplusplus
}
#endif
%>
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -