|
初学shell,要索引html,于是代码:
[code:1]
#!/bin/sh
echo '<html>'
echo '<head>'
echo '<title>My Index</tltle>'
echo '</head>'
echo '<body>'
echo '<h1>我的HTML文件</h1>'
for i in *
do
if [ -d $i ]
then
echo "<h2>$i</h2>"
echo '<ul>'
for j in $i/*.htm*
do
if [ -f $j ]
then
tline=`grep '<title>' $j`
if [ $? -eq 1 ]
then
ntitle=`basename $j | cut -f1 -d"."`
else
ntitle=`echo $tline | sed 's/^.*<title>//' | sed 's/<\/title>.*$//'`
fi
echo "<li><a herf=$j>$ntitle</a>"
fi
done
echo '</ul>'
fi
done
echo '</body>'
echo '</html>'
[/code:1]
结果在浏览器中什么也没有,生成的文档内容源代码:
[code:1]
<html>
<head>
<title>My Index</tltle>
</head>
<body>
<h1>我的HTML文件</h1>
<h2>cgi-bin</h2>
<ul>
</ul>
<h2>error</h2>
<ul>
<li><a herf=error/contact.html.var>contact</a>
<li><a herf=error/HTTP_BAD_GATEWAY.html.var>HTTP_BAD_GATEWAY</a>
<li><a herf=error/HTTP_BAD_REQUEST.html.var>HTTP_BAD_REQUEST</a>
<li><a herf=error/HTTP_FORBIDDEN.html.var>HTTP_FORBIDDEN</a>
<li><a herf=error/HTTP_GONE.html.var>HTTP_GONE</a>
<li><a herf=error/HTTP_INTERNAL_SERVER_ERROR.html.var>HTTP_INTERNAL_SERVER_ERROR</a>
<li><a herf=error/HTTP_LENGTH_REQUIRED.html.var>HTTP_LENGTH_REQUIRED</a>
<li><a herf=error/HTTP_METHOD_NOT_ALLOWED.html.var>HTTP_METHOD_NOT_ALLOWED</a>
<li><a herf=error/HTTP_NOT_ACCEPTABLE.html.var>HTTP_NOT_ACCEPTABLE</a>
<li><a herf=error/HTTP_NOT_FOUND.html.var>HTTP_NOT_FOUND</a>
<li><a herf=error/HTTP_NOT_IMPLEMENTED.html.var>HTTP_NOT_IMPLEMENTED</a>
<li><a herf=error/HTTP_PRECONDITION_FAILED.html.var>HTTP_PRECONDITION_FAILED</a>
<li><a herf=error/HTTP_REQUEST_ENTITY_TOO_LARGE.html.var>HTTP_REQUEST_ENTITY_TOO_LARGE</a>
<li><a herf=error/HTTP_REQUEST_TIME_OUT.html.var>HTTP_REQUEST_TIME_OUT</a>
<li><a herf=error/HTTP_REQUEST_URI_TOO_LARGE.html.var>HTTP_REQUEST_URI_TOO_LARGE</a>
<li><a herf=error/HTTP_SERVICE_UNAVAILABLE.html.var>HTTP_SERVICE_UNAVAILABLE</a>
<li><a herf=error/HTTP_UNAUTHORIZED.html.var>HTTP_UNAUTHORIZED</a>
<li><a herf=error/HTTP_UNSUPPORTED_MEDIA_TYPE.html.var>HTTP_UNSUPPORTED_MEDIA_TYPE</a>
<li><a herf=error/HTTP_VARIANT_ALSO_VARIES.html.var>HTTP_VARIANT_ALSO_VARIES</a>
<li><a herf=error/noindex.html>noindex</a>
</ul>
<h2>html</h2>
<ul>
<li><a herf=html/cfgmaker.html>cfgmaker</a>
<li><a herf=html/contrib.html>contrib</a>
<li><a herf=html/faq.html>faq</a>
<li><a herf=html/forum.html>forum</a>
<li><a herf=html/index.html>index</a>
<li><a herf=html/indexmaker.html>indexmaker</a>
<li><a herf=html/logfile.html>logfile</a>
<li><a herf=html/mibhelp.html>mibhelp</a>
<li><a herf=html/mrtg.html>mrtg</a>
<li><a herf=html/mrtglib.html>mrtglib</a>
<li><a herf=html/mrtg-rrd.html>mrtg-rrd</a>
<li><a herf=html/nt-guide.html>nt-guide</a>
<li><a herf=html/reference.html>reference</a>
<li><a herf=html/squid.html>squid</a>
<li><a herf=html/unix-guide.html>unix-guide</a>
<li><a herf=html/webserver.html>webserver</a>
</ul>
<h2>icons</h2>
<ul>
</ul>
<h2>manual</h2>
<ul>
<li><a herf=manual/bind.html.en>Binding - Apache HTTP Server</a>
<li><a herf=manual/bind.html.ja.jis>$B%P%$%s%I(B - Apache HTTP Server</a>
<li><a herf=manual/cgi_path.html.en>PATH_INFO Changes in the CGI Environment</a>
<li><a herf=manual/cgi_path.html.ja.jis>CGI $B4D6-$N(B PATH_INFO $B$NJQ99(B</a>
<li><a herf=manual/configuring.html.en>Configuration Files - Apache HTTP Server</a>
<li><a herf=manual/configuring.html.ja.jis>$B@_Dj%U%!%$%k(B - Apache HTTP Server</a>
<li><a herf=manual/content-negotiation.html.en>Apache Content Negotiation</a>
<li><a herf=manual/content-negotiation.html.ja.jis>Apache $B%3%s%F%s%H%M%4%7%(!<%7%g%s(B</a>
<li><a herf=manual/custom-error.html.en>Custom error responses</a>
<li><a herf=manual/custom-error.html.ja.jis>$B%+%9%?%`%(%i!<%l%9%]%s%9(B</a>
<li><a herf=manual/dns-caveats.html>Issues Regarding DNS and Apache</a>
<li><a herf=manual/dso.html.en>Dynamic Shared Object (DSO) support</a>
<li><a herf=manual/dso.html.ja.jis>Dynamic Shared Object (DSO) support</a>
<li><a herf=manual/dso.html.ko.euc-kr>悼利傍蜡按眉 (DSO) 瘤盔</a>
<li><a herf=manual/ebcdic.html>The Apache EBCDIC Port</a>
<li><a herf=manual/env.html.en>Environment Variables in Apache - Apache HTTP Server</a>
<li><a herf=manual/env.html.ja.jis>Apache $B$N4D6-JQ?t(B</a>
<li><a herf=manual/filter.html.en>Filters - Apache HTTP Server</a>
<li><a herf=manual/filter.html.ja.jis>$B%U%#%k%?(B - Apache HTTPD</a>
<li><a herf=manual/footer.html>footer</a>
<li><a herf=manual/glossary.html>Glossary</a>
<li><a herf=manual/handler.html.en>Apache's Handler Use - Apache HTTP Server</a>
<li><a herf=manual/handler.html.ja.jis>Apache $B$N%O%s%I%i$N;HMQ(B</a>
<li><a herf=manual/header.html>header</a>
<li><a herf=manual/index.html.en>Apache HTTP Server Version 2.0 Documentation</a>
<li><a herf=manual/index.html.fr>Documentation du serveur HTTP Apache version 2.0</a>
<li><a herf=manual/index.html.ja.jis>Apache HTTP $B%5!<%P(B $B%P!<%8%g%s(B 2.0 $B%I%-%e%a%s%H(B</a>
<li><a herf=manual/index.html.ko.euc-kr>酒颇摹 汲摹 八荤侩 其捞瘤</a>
<li><a herf=manual/install.html.en>Compiling and Installing Apache</a>
<li><a herf=manual/install.html.ja.jis>Apache $B$N%3%s%Q%$%k$H%$%s%9%H!<%k(B</a>
<li><a herf=manual/install.html.ko.euc-kr>酒颇摹 哪颇老苞 汲摹</a>
<li><a herf=manual/invoking.html.en>Starting Apache</a>
<li><a herf=manual/invoking.html.ja.jis>Starting Apache</a>
<li><a herf=manual/logs.html.en>Log Files - Apache HTTP Server</a>
<li><a herf=manual/logs.html.ja.jis>Log Files - Apache HTTP Server</a>
<li><a herf=manual/mpm.html.en>Apache Multi-Processing Modules (MPMs)</a>
<li><a herf=manual/mpm.html.ja.jis>Apache Multi-Processing Modules (MPMs)</a>
<li><a herf=manual/mpm.html.ko.euc-kr>Apache Multi-Processing Modules (MPMs)</a>
<li><a herf=manual/new_features_2_0.html.de>New features with Apache 2.0</a>
<li><a herf=manual/new_features_2_0.html.en>New features with Apache 2.0</a>
<li><a herf=manual/new_features_2_0.html.fr>Nouvelles fonctionnalit&eacute;s d'Apache 2.0</a>
<li><a herf=manual/new_features_2_0.html.ja.jis>New features with Apache 2.0</a>
<li><a herf=manual/new_features_2_0.html.ko.euc-kr>Apache 2.0狼 货肺款 扁瓷</a>
<li><a herf=manual/sections.html.en>How Directory, Location and Files sections work</a>
<li><a herf=manual/sections.html.ja.jis>How Directory, Location and Files sections work</a>
<li><a herf=manual/server-wide.html.en>Server-Wide Configuration</a>
<li><a herf=manual/server-wide.html.ja.jis>Server-Wide Configuration</a>
<li><a herf=manual/sitemap.html.en>Site Map - Apache HTTP Server 2.0</a>
<li><a herf=manual/sitemap.html.ja.jis>Site Map - Apache HTTP Server 2.0</a>
<li><a herf=manual/stopping.html.en>Stopping and Restarting the Server</a>
<li><a herf=manual/stopping.html.ja.jis>$BDd;_$H:F5/F0(B</a>
<li><a herf=manual/suexec.html.en>Apache suEXEC Support</a>
<li><a herf=manual/suexec.html.ja.jis>Apache suEXEC Support</a>
<li><a herf=manual/upgrading.html.en>Upgrading to 2.0 from 1.3</a>
<li><a herf=manual/upgrading.html.fr>Mise &agrave; jour de la version 1.3 &agrave; la version</a>
<li><a herf=manual/upgrading.html.ja.jis>Upgrading to 2.0 from 1.3</a>
<li><a herf=manual/upgrading.html.ko.euc-kr>Upgrading to 2.0 from 1.3</a>
<li><a herf=manual/urlmapping.html.en>Mapping URLs to Filesystem Locations - Apache HTTP</a>
<li><a herf=manual/urlmapping.html.ja.jis>Mapping URLs to Filesystem Locations - Apache HTTP</a>
</ul>
<h2>nut-cgi-bin</h2>
<ul>
</ul>
<h2>wordtrans</h2>
<ul>
</ul>
</body>
</html>
[/code:1]
请教问题出在什么地方. |
|