GSP - A simple example : unix shell version.

 GSP Home  Previous  Next

Always the same example, now showing unix shell handling.

the GSP source page : sh.gsp 

<html>
<%@ language="sh"
    mime type = "text/html"
    %>
<%!
 #
 # a comment to test the ! tag
 #
%>
<body>
<%
    HELLO="Hello world";
    A=20;
    B=22;
    C=`expr $A + $B`;
%>
<h1><%=$HELLO%></h1>
<p>The answer is <%=$C%></p>
</body>
</html>

Invoking GSP to produce the cgi shell script 

bash# gsp -o gsp-sh.sh -m sh.gsp

This command will produce one file :

gsp-sh.sh

#!/bin/sh

#
# a comment to test the ! tag
# 
sh_gsp()
{
echo -ne "Content-Type: "
echo -ne "text/html"
echo -ne "\n\n"
echo -ne "<html>\n"
echo -ne "\n"
echo -ne "\n<body>\n"

    HELLO="Hello world";
    A=20;
    B=22;
    C=`expr $A + $B`;
echo -ne "\n<h1>"
echo -ne $HELLO
echo -ne "</h1>\n<p>The answer is "
echo -ne $C
echo -ne "</p>\n</body>\n</html>\n"
}

if [ "empty" = $PATH_INFO"empty" ] ; then
    requestedPage="sh.gsp"
else
    requestedPage=$PATH_INFO
fi
firstChar=`expr substr $requestedPage 1 1`
if [ $firstChar = "/" ] ; then
    requestedPage=`expr substr $requestedPage 2 255`
fi
case $requestedPage in
    "") sh_gsp
        ;;
    "sh.gsp") sh_gsp
        ;;
esac


Ready to use ! 

Just copy it to your http server cgi-bin folder.

 début de page  GSP Home  Previous  Next last update 01/18/2004 - 17:27