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

📄 asg05.htm

📁 apache技术手册
💻 HTM
📖 第 1 页 / 共 5 页
字号:

<TD VALIGN=top  BGCOLOR=#80FFFF ><FONT COLOR=#000080>

<A HREF="javascript:if(confirm('ftp://ftp.rge.com/pub/languages/perl/CPAN/  \n\nThis file was not retrieved by Teleport Pro, because it did not meet the project\'s file type specifications.  \n\nDo you want to open it from the server?'))window.location='ftp://ftp.rge.com/pub/languages/perl/CPAN/'" tppabs="ftp://ftp.rge.com/pub/languages/perl/CPAN/"> ftp://ftp.rge.com/pub/languages/perl/CPAN/</A>

</FONT>

<TR>

<TD VALIGN=top  BGCOLOR=#80FFFF ><FONT COLOR=#000080>

Oklahoma

</FONT>

<TD VALIGN=top  BGCOLOR=#80FFFF ><FONT COLOR=#000080>

<A HREF="javascript:if(confirm('ftp://ftp.uoknor.edu/mirrors/CPAN/  \n\nThis file was not retrieved by Teleport Pro, because it did not meet the project\'s file type specifications.  \n\nDo you want to open it from the server?'))window.location='ftp://ftp.uoknor.edu/mirrors/CPAN/'" tppabs="ftp://ftp.uoknor.edu/mirrors/CPAN/"> ftp://ftp.uoknor.edu/mirrors/CPAN/</A>

</FONT>

<TR>

<TD VALIGN=top  BGCOLOR=#80FFFF ><FONT COLOR=#000080>

Texas

</FONT>

<TD VALIGN=top  BGCOLOR=#80FFFF ><FONT COLOR=#000080>

<A HREF="javascript:if(confirm('ftp://ftp.sedl.org/pub/mirrors/CPAN/  \n\nThis file was not retrieved by Teleport Pro, because it did not meet the project\'s file type specifications.  \n\nDo you want to open it from the server?'))window.location='ftp://ftp.sedl.org/pub/mirrors/CPAN/'" tppabs="ftp://ftp.sedl.org/pub/mirrors/CPAN/"> ftp://ftp.sedl.org/pub/mirrors/CPAN/</A>

<BR><A HREF="javascript:if(confirm('ftp://ftp.metronet.com/pub/perl/  \n\nThis file was not retrieved by Teleport Pro, because it did not meet the project\'s file type specifications.  \n\nDo you want to open it from the server?'))window.location='ftp://ftp.metronet.com/pub/perl/'" tppabs="ftp://ftp.metronet.com/pub/perl/"> ftp://ftp.metronet.com/pub/perl/</A>

<BR><A HREF="javascript:if(confirm('ftp://ftp.sterling.com/CPAN/  \n\nThis file was not retrieved by Teleport Pro, because it did not meet the project\'s file type specifications.  \n\nDo you want to open it from the server?'))window.location='ftp://ftp.sterling.com/CPAN/'" tppabs="ftp://ftp.sterling.com/CPAN/"> ftp://ftp.sterling.com/CPAN/</A>

</FONT>

<TR>

<TD ALIGN=center  VALIGN=top  BGCOLOR=#80FFFF ><FONT COLOR=#000080>

<I>South America</I>

</FONT>

<TD ALIGN=center  VALIGN=top  BGCOLOR=#80FFFF ><FONT COLOR=#000080><BR></FONT>



<TR>

<TD VALIGN=top  BGCOLOR=#80FFFF ><FONT COLOR=#000080>

Chile

</FONT>

<TD VALIGN=top  BGCOLOR=#80FFFF ><FONT COLOR=#000080>

<A HREF="javascript:if(confirm('ftp://sunsite.dcc.uchile.cl/pub/Lang/perl/CPAN/  \n\nThis file was not retrieved by Teleport Pro, because it did not meet the project\'s file type specifications.  \n\nDo you want to open it from the server?'))window.location='ftp://sunsite.dcc.uchile.cl/pub/Lang/perl/CPAN/'" tppabs="ftp://sunsite.dcc.uchile.cl/pub/Lang/perl/CPAN/"> ftp://sunsite.dcc.uchile.cl/pub/Lang/perl/CPAN/</A></FONT>

</TABLE><BR>

<A NAME="E70E4"></A>

<H5 ALIGN=CENTER>

<CENTER>

<FONT SIZE=4 COLOR="#FF0000"><B>CGI</B></FONT></CENTER></H5>

<BR>

<P>For CGI topics, you may want to check out <I>The CGI Book</I> by William E. Weinman, published by New Riders, ISBN 1-56205-571-2. Another good book is <I>CGI Programming Unleashed </I>by Dan Berlin, published by Sams Publishing, ISBN 1-57521-151-3. HTML and CGI Unleashed by John December and Mark Ginsburg, published by Sams.net Publishing, ISBN 0-672-30745-6, is a complete guide for the development of your Web content. Another good book, although already showing some age, is <I>Build a Web Site</I> by Net.Genesis and Devra Hall, published by Prima Online Books, ISBN 0-7615-0064-2.

<BR>

<P>On the Internet , the following addresses are good resources to check:

<BR>

<UL>

<LI><A HREF="news:comp.infosystems.www.authoring.cgi"> news:comp.infosystems.www.authoring.cgi</A>&#151;This newsgroup contains a lot information about authoring CGI. 

<BR>

<BR>

<LI> <A HREF="javascript:if(confirm('http://www.ncsa.uiuc.edu/Indices/WebTech/Docs.html  \n\nThis file was not retrieved by Teleport Pro, because it is addressed on a domain or path outside the boundaries set for its Starting Address.  \n\nDo you want to open it from the server?'))window.location='http://www.ncsa.uiuc.edu/Indices/WebTech/Docs.html'" tppabs="http://www.ncsa.uiuc.edu/Indices/WebTech/Docs.html"> http://www.ncsa.uiuc.edu/Indices/WebTech/Docs.html</A>&#151;This site has a lot of interesting information about CGI and other web technologies.

<BR>

<BR>

</UL>

<BR>

<A NAME="E70E5"></A>

<H5 ALIGN=CENTER>

<CENTER>

<FONT SIZE=4 COLOR="#FF0000"><B>World Wide Web</B></FONT></CENTER></H5>

<BR>

<BR>

<PRE>

<FONT COLOR="#000080"><A HREF="javascript:if(confirm('http://www.boutell.com/  \n\nThis file was not retrieved by Teleport Pro, because it is addressed on a domain or path outside the boundaries set for its Starting Address.  \n\nDo you want to open it from the server?'))window.location='http://www.boutell.com/'" tppabs="http://www.boutell.com/"> http://www.boutell.com</A></FONT></PRE>

<P>Maintained by Thomas Boutell, this site has a lot of interesting Web information. It is also home to MapEdit, a PC and X Window map-creation tool; Wusage, a Web server statistics package; and cgic, a library of routines for programming CGI in C.

<BR>

<BR>

<A NAME="E70E6"></A>

<H5 ALIGN=CENTER>

<CENTER>

<FONT SIZE=4 COLOR="#FF0000"><B>C and Shell (</B><B>sh</B><B>)</B></FONT></CENTER></H5>

<BR>

<P>If you want to learn how to program in C, there are a few million books out there that will serve you equally well. The authoritative one, <I>The C </I><I>Programming Language</I> by Brian W. Kernighan and Dennis M. Ritchie, published by Prentice-Hall, Inc., is a must.

<BR>

<P>Books are also available for sh programming; however, your system's online documentation may have enough to get you started. For those interested in using the csh as their command processor, check out <I>The </I><I>UNIX C Shell Field Guide</I> by Gail and Paul Anderson, published by Prentice-Hall, ISBN 0-13-937468-X. This book is an excellent reference on csh and various UNIX commands that you can use to create powerful scripts that get real work done. Another helpful book is <I>UNIX Unleashed</I>, published by Sams Publishing, ISBN 0-672-30402-3. It covers UNIX commands, features, and utilities in depth .

<BR>

<BR>

<A NAME="E68E37"></A>

<H3 ALIGN=CENTER>

<CENTER>

<FONT SIZE=5 COLOR="#FF0000"><B>Hello World</B><B>!</B></FONT></CENTER></H3>

<BR>

<P>The very first program most anyone writes in a new language is called Hello World!. The intention of Hello World! is to print the words Hello World, be it on the terminal or on a Web browser. I will provide you with three examples that say hello in Perl, C, and sh. Although I am not teaching you how to program, go get one of the books I've listed; These examples will show you what makes a CGI program different from other programs you may have developed.

<BR>

<P>The programs in Listings 5.1, 5.2, and 5.3 could have been written more compactly, but I have opted for multiple print calls and for placing of HTML tags one per line (unless the tag closes on the same line) for the sake of clarity. (If you are writing CGI, I assume that you are familiar with HTML tags; otherwise you may be well over your head, and you should perhaps take a look at <A HREF="asgxd.htm" tppabs="http://docs.rinet.ru:8080/Apachu/asgxd.htm">Appendix D</A>, &quot;HTML Reference.&quot;)

<BR>

<P>

<FONT COLOR="#000080"><A NAME="I4"></A><B>Listing 5.1. Hello World! as a </B><B>sh</B><B> CGI</B><B> .</B></FONT>

<BR>

<PRE>

<FONT COLOR="#000080">#!/bin/sh

# HelloInSh - A trivial example of a shell CGI

# This program returns html content. The very first line of this

# listing

# Comments lines used for providing more information to the programmer

# or documentation lines have the '#' character as the first character

# in the line. The first # symbol is special, it's not a comment.

# It informs the operating system to use the program /bin/sh

# as the command interpreter for the script that follows.

# The very first thing, we do on our CGI is tell the server

# what type of data we are returning, in this case it is html:

#

echo Content-type: text/html

#

# then we need to add a single line blank line, that separates the

# 'header' from the actual stuff in our output:

#

echo

#

# At this point we need to provide 'body' that includes all the usual

# tags and structure required by html.

# because some of the characters such as the angle brackets

# are interpreted by the sh as a redirection, we need to enclose them

# with a single quote:

#

echo '&lt;HTML&gt;'

echo '&lt;HEAD&gt;'

echo '&lt;TITLE&gt; Hello World!&lt;/TITLE&gt;'

echo '&lt;/HEAD&gt;'

echo '&lt;BODY&gt;'

echo '&lt;H1&gt;Hello World!&lt;/H1&gt;'

echo '&lt;/BODY&gt;'

echo '&lt;/HTML&gt;'</FONT></PRE>

<P>

<FONT COLOR="#000080"><A NAME="I5"></A><B>Listing 5.2. Hello World! as a Perl CGI program</B><B> .</B></FONT>

<BR>

<PRE>

<FONT COLOR="#000080">#!/usr/local/bin/perl

# HelloInPerl, a trivial example of a CGI in Perl

#

# Output appropriate header for server, we included two newlines, the '\n'.

#

print &quot;Content-type: text/html\n\n&quot;;

#

# Use a 'here' document format for easy readability and avoid need for many

# many printf() statements. All the lines following the print line are 'printed'

# verbatim, until the 'STOP' tag is found.

#

print &lt;&lt;STOP;

&lt;HTML&gt;

&lt;HEAD&gt;

&lt;TITLE&gt; Hello World!&lt;/TITLE&gt;

&lt;/HEAD&gt;

&lt;BODY&gt;

&lt;H1&gt;Hello World!&lt;/H1&gt;

&lt;/BODY&gt;

&lt;/HTML&gt;

STOP

#

# Now we tell the operating system that this run of the program proceeded without

# any errors by 'exiting' with a zero status.

#

exit(0);</FONT></PRE>

<P>

<FONT COLOR="#000080"><A NAME="I6"></A><B>Listing 5.3. Hello World! as a C CGI program</B><B> .</B></FONT>

<BR>

<PRE>

<FONT COLOR="#000080">/* HelloInC - A trivial example of a CGI in C. */

#include &lt;stdio.h&gt;

int main (void)

{

 printf (&quot;Content-type: text/html\n\n&quot;);

/* As our Perl or sh examples, the first thing to output is the Content-type */

 printf(&quot;&lt;HTML&gt;&quot;);

 printf(&quot;&lt;HEAD&gt;&quot;);

 printf(&quot;&lt;TITLE&gt;Hello World!&lt;/TITLE&gt;&quot;);

 printf(&quot;&lt;/HEAD&gt;&quot;);

 printf(&quot;&lt;BODY&gt;&quot;);

 printf(&quot;&lt;H1&gt;Hello World!&lt;/H1&gt;&quot;);

 printf(&quot;&lt;/BODY&gt;&quot;);

 printf(&quot;&lt;/HTML&gt;&quot;);

 return;

}</FONT></PRE>

<P>The C version of the program is the one that looks the oddest of the three examples. For one thing, C is more structured, and its syntax is more rigid. C is a <I>compiled</I> program, meaning that after you enter the code, you need to convert it into an executable program before you can run it. C offers low-level access to the OS, making it a very powerful programming language. Although CGIs in C are harder to implement that the equivalent Perl programs, C does have its own advantages. C programs run fast&#151;very fast. If your CGI is one that does many things and your server is under a heavy load, you may have no choice but to create an efficient program that creates the least impact on your system. C is a great tool for this.

<BR>

<P>Perl and sh are interpreted languages. <I>Interpreted</I> programs are executed by an interpreter&#151;such as the Perl, sh (Bourne shell), or another shell type program. Both languages allow you to do several things that would take many lines of code in C with very few commands. Both of these languages were designed with rapid development in mind.

<BR>

<P>In terms of debugging problems with your program, C may provide you with better tools that you can use to track problems in your code. Both Perl and sh provide you with ways to catch syntax errors, but certain types of errors may be a little harder to track.

<BR>

<BR>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -