首页

2010年5月29日星期六

Scheme/lisp 将打印出来的CGI变量写入文件中

#! /bin/sh
":"; exec /usr/bin/mzscheme -qr $0 $"@"

(display "content-type: text/plain")
(newline)
(newline)

(define my-list (cons (getenv "GATEWAY_INTERFACE")
                (cons (getenv "SERVER_NAME")
            (cons (getenv"SERVER_SOFTWARE")
        (cons (getenv "ACCEPT")
        (cons (getenv "ACCEPT_ENCODING")
        (cons (getenv "ACCEPT_LANGUAGE")
            (cons (getenv "AUTORIZATION")
                (cons (getenv "FORM")
                (cons (getenv "IF_MODIFIED_SINGCE")
                (cons (getenv "PRAGMA")
        (cons (getenv "REFFERER")
        (cons (getenv "USER_AGENT")
                (cons (getenv "REQUEST_METHOD")
                (cons (getenv "QUERY_STRING")
            (cons (getenv "CONTENT_LENGTH")
                (cons (getenv "AUTH_TYPE")
                (cons (getenv "CONTENT_FILE")
                (cons (getenv "SCRPT_NAME")
            (cons (getenv "REQUEST_METHOD")
                (cons (getenv"REQUEST_LINE")
                (cons (getenv "REMOTE_USER")
        (cons (getenv "REMOTE_ADDR")
                (cons (getenv "QUERY_STRING")
                (cons (getenv"PATH_TRANSLATED")
                (cons (getenv "PATH_INFO") '()))))))))))))))))))))))))))
(define my-out-list (lambda (x)
                      (begin
                        (display x)
                        (newline))))
(for-each my-out-list my-list)
(define my-getenv (lambda (x)
            (display (getenv x))
            (newline)
            (newline)))
;;(for-each my-getenv my-list)
(define out-list (lambda (put-file list-name)
                   (let loop ((out-name list-name))
                     (if (null?(cdr out-name))(write (car out-name) put-file)
                         (begin
                           (write (car out-name)put-file)
                           (newline put-file)
                          (loop (cdr out-name)))))
   (close-output-port put-file)))

(display "hello")

(define my-output-port (open-output-file "./server.info" #:exists 'truncate))
;;(write my-list my-output-port)
;;(close-output-port my-output-port)
(out-list my-output-port my-list)

没有评论:

发表评论