Results 1 to 3 of 3
Hi
I am new to cgi and shell programming
i have a cgi script that is accessed via browser
http://www.example.org/cgi-bin/myscr...c4167d83697a6f
before the script is executed i would like to do ...
- 03-21-2007 #1Just Joined!
- Join Date
- Mar 2007
- Posts
- 2
Need help to write a simple cgi shell script
Hi
I am new to cgi and shell programming
i have a cgi script that is accessed via browser
http://www.example.org/cgi-bin/myscr...c4167d83697a6f
before the script is executed i would like to do some checks
in php i would do this.
how can i write this in shell script? This is not a perl script. it starts withPHP Code:$secure_code = 'somerandomstringtosecure';
if ( md5 ($_GET['random'] . $secure_code) !== $_GET['hash'] ) {
die("access denied");
}
#!/bin/sh
Thanks
Shuja
- 03-21-2007 #2
I do not believe that you can write CGI scripts using Bash. However, a quick Google search reveals:
http://bashlib.sourceforge.net/
Try taking a look at that.DISTRO=Arch
Registered Linux User #388732
- 03-22-2007 #3Just Joined!
- Join Date
- Mar 2007
- Posts
- 2
After a lot of searching and learing i came up with following, might help anyone else
#!/bin/sh
echo "Content-type: text/html"
echo
echo "<pre>Syncing web ... "
echo
ST1=`echo $QUERY_STRING | cut '-d&' -f1`
ST2=`echo $QUERY_STRING | cut '-d&' -f2`
key=`echo $ST1 | cut -d= -f2`
hash=`echo $ST2 | cut -d= -f2`
secret="47e0a03523feddc35"
hash2=`md5sum --string="$key$secret" | cut -f1 -d ' '`
echo "$key"
if [ "x$key" == "x" ] ; then
echo "Key not given"
exit 1
fi
if [ "x$hash" == "x" ] ; then
echo "Hash not given"
exit 1
fi
if [ $hash != $hash2 ] ; then
echo "Test Failed"
exit 1
fi


Reply With Quote