prototype version
authordrowe67 <drowe67@01035d8c-6547-0410-b346-abe4f91aad63>
Mon, 29 Oct 2012 03:23:12 +0000 (03:23 +0000)
committerdrowe67 <drowe67@01035d8c-6547-0410-b346-abe4f91aad63>
Mon, 29 Oct 2012 03:23:12 +0000 (03:23 +0000)
git-svn-id: https://svn.code.sf.net/p/freetel/code@887 01035d8c-6547-0410-b346-abe4f91aad63

mini-asterisk-gui2/cgi-bin/setlinekey2.cgi [new file with mode: 0755]

diff --git a/mini-asterisk-gui2/cgi-bin/setlinekey2.cgi b/mini-asterisk-gui2/cgi-bin/setlinekey2.cgi
new file mode 100755 (executable)
index 0000000..673f876
--- /dev/null
@@ -0,0 +1,42 @@
+#!/bin/sh -x
+# setlinekey.cgi
+# David Rowe 29 Oct 2012
+#
+# CGI to set 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&key=mykey'; ./setlinekey.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"`
+key=`echo $QUERY_STRING | grep -oe "key=[^&?]*" | sed -n "s/key=//p" | sed "s/%22/\"/g"`
+echo $QUERY_STRING
+echo $file
+echo $this
+echo $that
+echo $key
+if [ -f $file ]; then
+#  sed -i  "s/\($this\)[a-z0-9\.]*\(.*$key.*\)/\1$that\2/"  $file
+  cat $file | sed "s/\($this\)[a-z0-9\.]*\(.*$key.*\)/\1$that\2/"
+else
+  echo "$file does not exist"
+fi
+cat <<EOF
+</body>
+</html>
+EOF