[thttpd 2탄] cgi 실행하면 앞에 꽁수를 부려야 실행이 됩니다.

삽질토비의 이미지

산넘어 산이라고,
하나 해결하니까, 또 부닥치는군요.

cgi 파일을 다음과 같이 만들어줬습니다.

#!/bin/sh
echo "AAAA"

이렇게 하면 실행 안되고, 아무 반응 없습니다.

그런데, 앞에다가 꽁수를 부리면 실행이 됩니다.

#!/bin/sh
/sbin/ifconfig lo # <- 꽁수부분
echo "BBBB"

꽁수부분이라고 해 놓은 부분을 추가해주면,
웹에서 실행시켰을때,
BBBB
라고만 뜹니다.
꽁수부분은 무시되는거죠.
그렇다고 꽁수부분에 다른걸 넣으면,
예를들어,
/bin/ls -al
이라고 넣으면 다시 안됩니다.

테스트 해본 결과 (다른 경우도 있겠지만, 일단 테스트 중에서)
/sbin/ifconfig lo 만 다음 라인부터 실행을 시켜줍니다.
쉘 스크립트를 cgi 로 돌리려면,
뭔가 설정이 필요한가요?

익명 사용자의 이미지

echo "Content-Type:text/plain"
echo
echo

이런 식으로 해야 하지 않을까요?

nthroot의 이미지

RFC HTTP 문서 보세요.

------식은이 처------
길이 끝나는 저기엔 아무 것도 없어요. 희망이고 나발이고 아무 것도 없어.

mrjh76의 이미지

사용하고 계신 thttpd 프로그램의 버그 아닐까요?

1탄의 질문에서 얘기드렸듯이.. 제 busybox 1.0의 httpd는 특별한 설정 없이도...

모든것이 잘 되거든요...

kihongss의 이미지

Anonymous wrote:
echo "Content-Type:text/plain"
echo
echo

이런 식으로 해야 하지 않을까요?

꼭 이런식으로 헤더를 표시해야 웹브라우저로 결과물이 출력됩니다. RFC 문서 보심이 제일 빠를것 같군요.

lifthrasiir의 이미지

RFC 3875(CGI 1.1)에 따르면, 6.2.1 Document Response에 다음과 같은 부분이 있습니다.

   The CGI script can return a document to the user in a document
   response, with an optional error code indicating the success status
   of the response.

      document-response = Content-Type [ Status ] *other-field NL
                          response-body

   The script MUST return a Content-Type header field.  A Status header
   field is optional, and status 200 'OK' is assumed if it is omitted.
   The server MUST make any appropriate modifications to the script's
   output to ensure that the response to the client complies with the
   response protocol version.

MUST라니 자명하지요? :)

- 토끼군

댓글 달기

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
이것은 자동으로 스팸을 올리는 것을 막기 위해서 제공됩니다.