💾 Archived View for tilde.team › ~steve › script_example.gmi captured on 2024-05-10 at 12:16:37. Gemini links have been rewritten to link to archived content

View Raw

More Information

⬅️ Previous capture (2021-12-03)

-=-=-=-=-=-=-

CGI Example

Back

Below is my simple comments cgi script. It just appends a user's input to a given file.

#!/bin/sh

if [ -z $QUERY_STRING ]; then
	printf "10 Please enter your comment and name: \r\n"
fi

decoded=`echo $QUERY_STRING |  perl -pe 's/\%(\w\w)/chr hex $1/ge'`
echo "\n"$decoded >> ../guestbook.gmi

# too much empty lines between comments
sed -i -z -e 's/\n\{4,\}/\n\n\n/g' ../guestbook.gmi

printf "30 ../guestbook.gmi\r\n"