펄 스크립트-test.cgi
:
#!/usr/bin/perl
use CGI qw(:standard);
print "Content-type: text/html\n\n";
print <<HTML;
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title>Document Title</title>
</head>
<body>
HTML
my $dir = '/home/lawlist/www';
my $query = new CGI;
my $name = $query->param('name');
my $file = $dir . "/" . $name;
opendir(DIR, $dir) or die $!;
while (my $file = readdir(DIR)) {
next unless (-f "$dir/$file");
next unless ($file =~ m/\.txt|\.el$/);
print '<a href="/cgi-bin/test.cgi?name=' . $file . '">' . $file . "</a>" . "<br>" . "\n\n"; }
closedir(DIR);
if ($name) {
open (DATA, $file) or return $self->print_json_error($self->language('ERR_CANNOT_OPEN', $file->{name}, $!));
read (DATA, my $file, -s DATA);
close DATA;
print '<pre class="brush: lisp">' . "\n\n" . $file . "\n" . '</pre>'; }
print <<HTML;
</body>
</html>
HTML
exit 0;
htaccess로 구성
DirectoryIndex index.html index.htm index.php index.cgi
SSLOptions +StdEnvVars
# Customized server error messages:
# ErrorDocument 404 /page.not.found.basic.html
AddHandler cgi-script .pl .cgi
Options +Includes +ExecCGI
AddType text/html .shtml .shtm .html .htm
AddHandler server-parsed .shtml .shtm .html .htm
# if you want to see the list of files in a directory
# without an index.html file, then uncomment the following line:
# Options +Indexes
Options -Indexes
# Options +FollowSymLinks
# Options Indexes Includes FollowSymLinks ExecCGI
웹 페이지 삽입 :
<hr COLOR="#CCCCCC" size=1 NOSHADE>
<!--#exec cgi="/cgi-bin/test.cgi"-->
<hr COLOR="#CCCCCC" size=1 NOSHADE>
네가 무엇을 요구하는지 모르겠다. [태그 : javescript]를 보면, 당신도 마찬가지라고 생각합니다. – bjb568
@ bjb568 - 질문의 명확한 설명이 필요하다는 사실을 알려 주셔서 감사합니다. 나는 몇 가지 샘플 코드와 필요한 것에 대한 더 나은 설명을 포함하도록 질문을 수정했다. 다른 포럼 참가자가 정중하게 답변을 게시했으며, 제안 된 내용에 대해 약간의 독해를해야 할 것입니다. 다시 한번 감사드립니다. 장래에는'javascript'와'html'의 태그를 모니터하는 사람들이 수천 명이 있다는 사실을 기억해야합니다. 그리고 게시하기 전에 제 질문을 더 잘 만들 거예요. – lawlist