<p style="margin: 10px auto; padding-top: 0px; padding-bottom: 0px; font-size: 13px; line-height: 19px; font-family: Verdana, Geneva, Arial, Helvetica, sans-serif;"><span style="font-size: 14px;"><span style="color: rgb(255, 0, 0);">结合:http://www.cnblogs.com/hnrainll/archive/2011/05/31/2064966.html</span></span></p><p style="margin: 10px auto; padding-top: 0px; padding-bottom: 0px; font-size: 13px; line-height: 19px; font-family: Verdana, Geneva, Arial, Helvetica, sans-serif;"><span style="font-size: 14px;"><span style="color: rgb(64, 0, 128);"> <span style="font-family: 楷体_GB2312;">我们可以用DreamWeaver来设计我们的网页,一般的情况下我们为动态的网页,就是说不是仅仅浏览,可以递交数据和查询我们要的东西,在嵌入式里面我是通过boa的web服务来调用cgi程序来实现交互的,如是怎么调用cgi就是一个很基础关键的问题,考,这个以前一点也不会,现在终于知道怎么回事了。</span></span></span></p><p style="margin: 10px auto; padding-top: 0px; padding-bottom: 0px; font-size: 13px; line-height: 19px; font-family: Verdana, Geneva, Arial, Helvetica, sans-serif;"><span style="font-family: 楷体_GB2312; font-size: 14px; color: rgb(64, 0, 128);"> 关键点:我是通过表单的方式来调用的,当然你也有其他的方式来调用cgi但是常用的还是cgi.我们先电击DreamWeaver的插入工具栏,在里面选择表单,在弹出的子菜单里面选择表单(F),这样你就可以用这个表单来提交数据和选择来调用你的cgi程序,在这个表单里面你可以添加你想要的控件,象文本框,按键之类的东西,好了原后你切换换到你的代码模式,在你的表单的action上面填写你的cgi的程序就可以了。</span></p><p style="margin: 10px auto; padding-top: 0px; padding-bottom: 0px; font-size: 13px; line-height: 19px; font-family: Verdana, Geneva, Arial, Helvetica, sans-serif;"><span style="font-family: 楷体_GB2312; font-size: 14px; color: rgb(64, 0, 128);"> 示例:</span></p><p style="margin: 10px auto; padding-top: 0px; padding-bottom: 0px; font-size: 13px; line-height: 19px; font-family: Verdana, Geneva, Arial, Helvetica, sans-serif;"><span style="font-size: 14px;"><%@LANGUAGE="JAVASCRIPT" CODEPAGE="936"%> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "</span><a target=_blank target="_blank" href="http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd%22" style="color: navy; text-decoration: none;"><span style="font-size: 14px;">http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"</span></a><span style="font-size: 14px;">> <html xmlns="</span><a target=_blank target="_blank" href="http://www.w3.org/1999/xhtml%22" style="color: navy; text-decoration: none;"><span style="font-size: 14px;">http://www.w3.org/1999/xhtml"</span></a><span style="font-size: 14px;">> <head> <meta http-equiv="Content-Type" content="text/html; charset=gb2312" /> <title>无标题文档</title> <style type="text/css"> <!-- #Layer1 { position:absolute; width:253px; height:94px; z-index:1; left: 373px; top: 120px; } --> </style> </head></span></p><p style="margin: 10px auto; padding-top: 0px; padding-bottom: 0px; font-size: 13px; line-height: 19px; font-family: Verdana, Geneva, Arial, Helvetica, sans-serif;"><span style="font-size: 14px;"><body> <div id="Layer1"> <span style="color: rgb(128, 0, 255);"><form id="form1" name="form1" method="post" action="passwd.cgi"></span> <p> user: <input type="text" name="textfield" /> </p> <p>pawd: <input type="text" name="textfield2" /> </p> <p> <input type="submit" name="Submit" value="提交" /> </p> </form> </div> </body> </html></span></p><p style="margin: 10px auto; padding-top: 0px; padding-bottom: 0px; font-size: 13px; line-height: 19px; font-family: Verdana, Geneva, Arial, Helvetica, sans-serif;"><a target=_blank target="_blank" href="http://images.cnblogs.com/cnblogs_com/xmphoenix/201103/201103202108334124.jpg" style="color: navy; text-decoration: none;"><img title="cgi_t1" height="187" alt="cgi_t1" src="http://images.cnblogs.com/cnblogs_com/xmphoenix/201103/201103202108385024.jpg" width="244" border="0" style="border: 0px; max-width: 100%; display: inline;" /></a> <a target=_blank target="_blank" href="http://images.cnblogs.com/cnblogs_com/xmphoenix/201103/201103202108509309.jpg" style="color: navy; text-decoration: none;"><img title="cgi_t2" height="190" alt="cgi_t2" src="http://images.cnblogs.com/cnblogs_com/xmphoenix/201103/201103202108511096.jpg" width="244" border="0" style="border: 0px; max-width: 100%; display: inline;" /></a></p>
//viewdata.c #include<stdio.h> #include<stdlib.h> #include<ctype.h> #define DATAFILE "/var/www/cgi-bin/data.txt" int main(void) { FILE *f = fopen(DATAFILE,"r"); char ch; char wendu[10]; char shidu[10]; char stime[20]; int i=0; int j=0; int k=0; int flag=0; if(f == NULL) //判断打开文件是否成功 { printf("Content-type:text/html;charset=gb2312\n\n"); printf("<TITLE>错误</TITLE>"); printf("<p><EM>意外错误,无法打开文件</EM>"); } else//打开文件成功,开始输出网页 { printf("Content-type:text/html\n\n"); printf("<html>\n"); printf("<head><title>viewdata</title></head>\n"); printf("<body>\n"); printf("温度:"); while((ch=getc(f))!='\n') //判断是否到了一行的末尾 { if(ch!=' '&&flag==0) //flag=0表示正在读温度 { wendu=ch; i++; } else if(flag==0) { wendu='\0'; flag=1; printf("%s",wendu); printf("<br>湿度:"); continue; } else if(ch!=' '&&flag==1) //flag=1表示正在读湿度 { shidu[j]=ch; j++; } else if(flag==1) { shidu[j]='\0'; flag=2; //flag=2表示读取时间 printf("%s<br>时间:",shidu); continue; } else { stime[k]=ch; k++; } } stime[k]='\0'; printf("%s",stime); printf("</body>\n"); printf("</html>"); fclose(f); } return 0; } //data.txt内容如下: 37.3 28.5 14:59:01 37.3 28.5 14:59:02 37.3 28.5 14:59:03 37.3 28.5 14:59:04 37.3 28.5 14:59:05 37.3 28.5 14:59:06 37.3 28.5 14:59:07 37.3 28.5 14:59:08 37.3 28.5 14:59:09 37.3 28.5 14:59:10 //gcc -o viewdata.cgi viewdata.c 生成cgi程序 //然后在网页中输入 <a target=_blank target="_blank" href="http://10.1.14.196/html/viewdata.cgi" rel="nofollow" style="color: rgb(45, 100, 179); text-decoration: none;">http://10.1.14.196/html/viewdata.cgi</a>后 //运行结果如下: 温度:37.3 湿度:28.5 时间:14:59:01