git-svn-id: https://svn.code.sf.net/p/freetel/code@862 01035d8c-6547-0410-b346-abe4f9...
authorhorse69 <horse69@01035d8c-6547-0410-b346-abe4f91aad63>
Sun, 28 Oct 2012 22:36:41 +0000 (22:36 +0000)
committerhorse69 <horse69@01035d8c-6547-0410-b346-abe4f91aad63>
Sun, 28 Oct 2012 22:36:41 +0000 (22:36 +0000)
mini-asterisk-gui2/cgi-bin/setword.cgi [new file with mode: 0644]

diff --git a/mini-asterisk-gui2/cgi-bin/setword.cgi b/mini-asterisk-gui2/cgi-bin/setword.cgi
new file mode 100644 (file)
index 0000000..3bb561e
--- /dev/null
@@ -0,0 +1,39 @@
+#!/bin/sh
+# setword.cgi
+# Ian Roberts 29 Oct 2012
+#
+# CGI to replace the text in "file" from "this" to "that"
+#
+# Test on host with:
+#
+#    $ export QUERY_STRING='file=test.txt&this=IPADDRESS&that="192.168.1.31"'; ./setword.cgi
+#
+
+cat <<EOF
+Content-type: text/html
+
+<html>
+<head>
+<meta http-equiv="cache-control" content="no-cache">
+<meta http-equiv="pragma" content="no-cache">
+<meta http-equiv="expires" content="-1"></head></head>
+<body>
+EOF
+
+file=`echo $QUERY_STRING | grep -oe "file=[^&?]*" | sed -n "s/file=//p"`
+this=`echo $QUERY_STRING | grep -oe "this=[^&?]*" | sed -n "s/this=//p" | sed "s/%22/\"/g"`
+that=`echo $QUERY_STRING | grep -oe "that=[^&?]*" | sed -n "s/that=//p" | sed "s/%22/\"/g"`
+echo $QUERY_STRING
+echo $file
+echo $this
+echo $that
+if [ -f $file ]; then
+  sed -i "s/$this.*/$that/g" $file
+else
+  echo "$file does not exist"
+fi
+cat <<EOF
+</body>
+</html>
+EOF