CGI 관련 질문입니다.

orangeloup의 이미지

제가 지금 perl을 이용해서 검색 시스템을 구현 중인데요

apm을 깔아서 아파치로 perl하고 연동해서 cgi로 구현을

하려고 간단한 테스트 삼아 html로 검색창을 하나 만들어서 검색

창에 입력한 문자를 cgi 로 받아서 실행 시키는 테스트를

하려고 했는데 submit 버튼을 누르면 실행이 되는 것이 아니라

파일 다운로드 받는 것 처럼 되버립니다.

ExecCGI 설정도 해주라는 데로 다 해줬는데 해결이 안되네요 ..

어떤 문제점이 있을지 지적해주시면 감사하겠습니다.

ageldama의 이미지

cotent-type header을 보내주세요.

print "Content-type: text/html\n\n";

...정도로

----
The future is here. It's just not widely distributed yet.
- William Gibson

----
The future is here. It's just not widely distributed yet.
- William Gibson

orangeloup의 이미지

#!c:/perl/bin/perl.exe

if($ENV{"REQUEST_METHOD"} eq "GET"){
$str = $ENV{"QUERY_STRING"};
}
else{
read(STDIN, $str, $ENV{"CONTENT_LENGTH"});
}
$str =~tr/+/ /;
$str =~ s/%[0-9A-Fa-f][0-9A-Fa-f])/pack("c", hex($1)) /eg;
$str =~ s/name=/ /;

print "Content-type: text/html\n\n";
print "

\n";
print "<head><title>ok</title></head>\n"
print "<body>$str</body>\n";
print "
\n";

이게 지금 제가 테스트 해보려고하는 cgi의 코드인데요 헤더도 설정 했는데 안되네요 ;;;

html 부분은 덧글에서는 안보이는데 뉴라인 앞에 있습니다.

ageldama의 이미지

둘중 하나일것 같은데요.

1. content-type header 전에 print한 내용이 있다.
2. 웹서버측 설정에서 기본 content-type을 달리하고 있다.

확인해보세요. ^^

----
The future is here. It's just not widely distributed yet.
- William Gibson

----
The future is here. It's just not widely distributed yet.
- William Gibson

keke111의 이미지

아파치에 확장자 처리가 안된거 같은데
addhandler 인가 부분에서 cgi부분이있는데 그 부분의 주석을 풀어 주시면 되는거 같은데요?

aero의 이미지

Perl에는 이미 http://perldoc.perl.org/CGI.html 라는 모듈이 기본으로 제공되는데
왜 CGI를 짜시면서 바닥부터 표준입력을 읽어서 맨손으로 parsing 하시나요?
CGI의 동작원리를 바닥부터 이해할려는 공부의 목적이 아니면 그냥 편하게 CGI모듈을
사용하시는게 나을듯 하네요.

orangeloup의 이미지

addhandler 쪽은 이미 주석 해제 하였구요

content-type도 이상이 없는데

이게 됐다가 안됐다가 그러네요 ...

그리고 제가 프로잭트하면서 그냥 맨땅에 헤딩식이라 ..

모듈이 있는 지도 몰랐네요 ㅠㅠ

댓글 달기

Filtered HTML

  • 텍스트에 BBCode 태그를 사용할 수 있습니다. URL은 자동으로 링크 됩니다.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>
  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.

BBCode

  • 텍스트에 BBCode 태그를 사용할 수 있습니다. URL은 자동으로 링크 됩니다.
  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param>
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.

Textile

  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • You can use Textile markup to format text.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>

Markdown

  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • Quick Tips:
    • Two or more spaces at a line's end = Line break
    • Double returns = Paragraph
    • *Single asterisks* or _single underscores_ = Emphasis
    • **Double** or __double__ = Strong
    • This is [a link](http://the.link.example.com "The optional title text")
    For complete details on the Markdown syntax, see the Markdown documentation and Markdown Extra documentation for tables, footnotes, and more.
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>

Plain text

  • HTML 태그를 사용할 수 없습니다.
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.
  • 줄과 단락은 자동으로 분리됩니다.
댓글 첨부 파일
이 댓글에 이미지나 파일을 업로드 합니다.
파일 크기는 8 MB보다 작아야 합니다.
허용할 파일 형식: txt pdf doc xls gif jpg jpeg mp3 png rar zip.
CAPTCHA
이것은 자동으로 스팸을 올리는 것을 막기 위해서 제공됩니다.