亚洲av成人无遮挡网站在线观看,少妇性bbb搡bbb爽爽爽,亚洲av日韩精品久久久久久,兔费看少妇性l交大片免费,无码少妇一区二区三区

  免費(fèi)注冊(cè) 查看新帖 |

Chinaunix

  平臺(tái) 論壇 博客 文庫(kù)
最近訪問板塊 發(fā)新帖
查看: 2144 | 回復(fù): 1
打印 上一主題 下一主題

CGI問題,高手指教.502 Bad Gateway [復(fù)制鏈接]

論壇徽章:
0
跳轉(zhuǎn)到指定樓層
1 [收藏(0)] [報(bào)告]
發(fā)表于 2009-10-24 10:29 |只看該作者 |倒序?yàn)g覽
CGI問題,高手指教.502 Bad Gateway
我在開發(fā)板上移植好boa后.
測(cè)試 hello.cgi 成功.
#include <stdio.h>
int  main()
{

    printf("Content-type: text/html\n\n");
    printf(" <html>\n");
    printf(" <head>\n");
    printf(" <title>my page </title>\n");
    printf(" <h1>hello world </h1>");
    printf(" </head>\n");
    printf(" </HTML>\n");
  return 0;
}
http://192.168.1.5/hello.cgi 顯示hello world

但測(cè)試另一個(gè)程序后,出現(xiàn)以下錯(cuò)誤:
502 Bad Gateway
The CGI was not CGI/1.1 compliant.

我的網(wǎng)頁代碼:
<html>
<head> <title>LED Control </title> </head>
<body>
<h1>This is my first web program </h1>
<img align="middle" src="success.jpg">
<br>
<br>
<form method="GET" action="/cgi-bin/test_led.cgi">
<h2>Input led number: </h2>
NO.: <input type=text name=no> <br>
<h3>(Notice!! the number is: 1-4) </h3> <br>
Status: <input type=text name=status>
<h3>Notice!!(1: on, 0: off) </h3> <br>
<p align="center"> <input type=submit value="  OK">
</form>
<p align="center">
</body>
</html>

單擊確定后:網(wǎng)址為:http://192.168.1.5/cgi-bin/test_led.cgi?no=1&amp;status=0

測(cè)試程序:
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/ioctl.h>
#include <string.h>

#define MAX_ARG 150

int main(void)
{

unsigned int led_no;
int fd = -1;
char para1[MAX_ARG], para2[MAX_ARG];
char value1[MAX_ARG], value2[MAX_ARG];

printf("%s%c%c ", "Content-Type:text/html", 13, 10);
printf(" <title>control result </title>");

char *buf = getenv("QUERY_STRING");
if (buf == NULL)
{
printf(" <error! there is no data!>");
return -1;
}

char *p = strchr(buf, '&');
*p = '\0';
strcpy(para1, buf);
strcpy(para2, p + 1);

p = strchr(para1, '=');
*p = '\0';
strcpy(value1, p + 1);

p = strchr(para2, '=');
*p = '\0';
strcpy(value2, p + 1);

int num, status;
num = atoi(value1);
status = atoi(value2);

fd = open("/dev/mini2440_led", 0);
if (fd < 0)
{
printf(" <p>error! open fail");
return -1;
}

if ((num - 1) > 3)
{
goto err;
}

ioctl(fd, status, num);
printf(" <p>sucess!");
close(fd);
return 0;
err:
if (fd > 0)
close(fd);
printf(" <p>data error!");
return -1;

}


請(qǐng)問是不是我編寫的CGI程序有問題?還是我只編寫了一個(gè)網(wǎng)頁的原因?請(qǐng)高手指教,還是我傳遞參數(shù)錯(cuò)誤?十萬火急!

論壇徽章:
0
2 [報(bào)告]
發(fā)表于 2009-10-24 13:38 |只看該作者
你說你測(cè)試hello world成功,但是你沒有測(cè)試hello world傳入?yún)?shù)是否成功啊。
你先寫一個(gè)能正確顯示傳入的參數(shù)的cgi試試。
您需要登錄后才可以回帖 登錄 | 注冊(cè)

本版積分規(guī)則 發(fā)表回復(fù)

  

北京盛拓優(yōu)訊信息技術(shù)有限公司. 版權(quán)所有 京ICP備16024965號(hào)-6 北京市公安局海淀分局網(wǎng)監(jiān)中心備案編號(hào):11010802020122 niuxiaotong@pcpop.com 17352615567
未成年舉報(bào)專區(qū)
中國(guó)互聯(lián)網(wǎng)協(xié)會(huì)會(huì)員  聯(lián)系我們:huangweiwei@itpub.net
感謝所有關(guān)心和支持過ChinaUnix的朋友們 轉(zhuǎn)載本站內(nèi)容請(qǐng)注明原作者名及出處

清除 Cookies - ChinaUnix - Archiver - WAP - TOP