⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 exec.csp

📁 eybuild-x86-arm920t-2.6.7.tar 很好的嵌入式WEB开发环境
💻 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 + -