see environment variables using CGI Script


The web server will execute the CGI script in its own process space but will set some useful environment variables. To view these, use the following script: /var/www/cgi-bin/env.sh 


#!/bin/sh

echo Content-type: text/html
echo ""

/bin/cat << EOM
<HTML>
<HEAD><TITLE>File Output: /home/user1/public_html/text-file.txt </TITLE>
</HEAD>
<BODY bgcolor="#cccccc" text="#000000">
<P>
<SMALL>
<PRE>
EOM

/bin/env

CAT << EOM
</PRE>
</SMALL>
<P>
</BODY>
</HTML>
EOM

Make script executable: chmod ugo+x env.sh

Test: http://localhost/cgi-bin/env.sh

When you execute the env.sh file, you will see the environment variables provided by the web server.





Added on January 3, 2008 Comment
}