0
我在Haskell中編寫了一個cgi腳本。 我只限於使用擁抱/ runhugs。在沒有包的情況下使用haskell/hugs獲取cgi中的環境變量
#!/opt/local/bin/runhugs
module Main where
main = do
putStrLn ("content-type: text/plain\n")
putStrLn ("Hello, Server!")
到目前爲止好。 但現在我想獲得服務器的環境變量。 例如「SCRIPT_NAME」環境變量。
使用bash我可以這樣做:
#!/bin/bash
echo "content-type: text/plain;"
echo ""
echo $SCRIPT_NAME
有了結果:/path/to/script.cgi
在瀏覽器窗口。
Haskell的我發現了一些相似:script <- getEnv "SCRIPT_NAME"
, 但
#!/opt/local/bin/runhugs
module Main where
main = do
putStrLn ("content-type: text/plain\n")
scriptname <- getEnv "SCRIPT_NAME"
putStrLn scriptname
不起作用。
是否有可能以某種方式做到這一點?
- 平原沒有進口,或者
- 在擁抱可能進口