运行在Apache .exe文件? [英] Run an .exe file on apache?

查看:229
本文介绍了运行在Apache .exe文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图通过运行一个HTML格式的CGI可执行文件在本code:

 < HTML和GT; < HEAD>
<标题> CGI表格及LT; /标题>
< META HTTP-EQUIV =内容类型内容=text / html的;字符集= UTF-8/>
< /头><身体GT;
<形式的行动=C:\\ WWW \\ cgi-bin目录\\ y.exe的方法=获取>
    <输入类型=文本名称=字符串1/>
    <输入类型=文本名称=字符串2/>
    <输入类型=文本名称=STRING3/>
    <输入类型=提交名称=提交值=提交/>
< /表及GT;
< /身体GT;< / HTML>

在这里,它是CGI code编译为y.exe并保存在操作中指定的路径:

 的#include<&stdio.h中GT;
#包括LT&;&stdlib.h中GT;
#包括LT&;&string.h中GT;INT主要(无效)
{
字符*缓冲液,字符串1 [100],字符串2 [100],STRING3 [100],合并[300];缓冲= GETENV(QUERY_STRING);如果(缓冲== NULL)
{
    的printf(< P>错误:没有数据< / P>中);
}
其他
{
    如果(sscanf的(缓冲区!字符串1 =%S&放大器;字符串2 =%S&安培; STRING3 =%S,字符串1,字符串,STRING3)= 3)
    {
        的printf(数据丢失!);
    }
    其他
    {
        的strcpy(合并,字符串1);
        strcat的(合并​​,字符串2);
        strcat的(合并​​,STRING3);        的printf(内容类型:text / html的\\ n \\ n);
        的printf(< HTML和GT; \\ N
               < HEAD> \\ N
                   <标题> CGI表单合并弦< /标题> \\ N
               < /头> \\ N
               <身体GT; \\ N
                   合并后的字符串是:%S \\ n
               < /身体GT; \\ N
               < / HTML> \\ N,合并);
    }
}返回0;

}

我试图重新配置httpd.conf文件与此:

  AddHandler的CGI脚本的.exe
ScriptAlias​​指令/的cgi-bin /C:/ WWW / cgi-bin目录/

 <目录C:/ WWW / cgi-bin目录>
    所有的AllowOverride
    选项​​+ ExecCGI
    有FollowSymLinks
    要求所有批准
    AddHandler的CGI脚本的CGI
    AddHandler的CGI脚本的.exe
< /目录>

然而,这并不解决问题。


解决方案

  ACTION =C:\\ WWW \\ cgi-bin目录\\ y.exe

您需要给一个HTTP URI这里。这将可能是:

 行动=/ cgi-bin目录/ y.exe

I'm trying to run a cgi executable file through a html form as in this code:

 <html>

 <head>
<title>CGI Form</title>
<meta http-equiv="content-type" content="text/html;charset=utf-8" />
</head>

<body>
<form action="C:\WWW\cgi-bin\y.exe" method="get">
    <input type="text" name="string1" />
    <input type="text" name="string2" />
    <input type="text" name="string3" />
    <input type="submit" name="submit" value="Submit" />
</form>
</body>

</html>

And here it is the cgi code compiled as y.exe and saved in the path specified in the action:

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main(void)
{
char *buffer, string1[100], string2[100], string3[100], merged[300]; 

buffer = getenv("QUERY_STRING"); 

if(buffer == NULL) 
{
    printf("<p>Error: No data</p>");
}
else
{
    if(sscanf(buffer, "string1=%s&string2=%s&string3=%s", string1, string2, string3) !=      3) 
    {
        printf("Data missing!");
    }
    else
    {   
        strcpy(merged, string1); 
        strcat(merged, string2); 
        strcat(merged, string3); 

        printf("Content-Type: text/html\n\n");
        printf("<html>\n"
               "<head>\n"
                   "<title>CGI Form Merge Strings</title>\n"
               "</head>\n"
               "<body>\n"
                   "Merged string is: %s\n"
               "</body>\n"
               "</html>\n", merged);  
    }
}

return 0;

}

I've tried to reconfigure the httpd.conf file with this:

AddHandler cgi-script .exe
ScriptAlias /cgi-bin/ "C:/WWW/cgi-bin/"

and

<Directory "C:/WWW/cgi-bin">
    AllowOverride All
    Options +ExecCGI
    Options FollowSymLinks 
    Require all granted
    AddHandler cgi-script .cgi
    AddHandler cgi-script .exe
</Directory>

However this does not fix the problem.

解决方案

action="C:\WWW\cgi-bin\y.exe" 

You need to give an HTTP URI here. It will probably be:

action="/cgi-bin/y.exe" 

这篇关于运行在Apache .exe文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆