added comment and uncomment scripts
authordrowe67 <drowe67@01035d8c-6547-0410-b346-abe4f91aad63>
Tue, 30 Oct 2012 04:26:50 +0000 (04:26 +0000)
committerdrowe67 <drowe67@01035d8c-6547-0410-b346-abe4f91aad63>
Tue, 30 Oct 2012 04:26:50 +0000 (04:26 +0000)
git-svn-id: https://svn.code.sf.net/p/freetel/code@898 01035d8c-6547-0410-b346-abe4f91aad63

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

diff --git a/mini-asterisk-gui2/cgi-bin/commentkey.cgi b/mini-asterisk-gui2/cgi-bin/commentkey.cgi
new file mode 100755 (executable)
index 0000000..afaf43d
--- /dev/null
@@ -0,0 +1,44 @@
+#!/bin/sh 
+# commentkey.cgi
+# David Rowe 30 Oct 2012
+#
+# CGI to comment a chunk of text that has a certain key phrase on each line
+#
+# Test on host with:
+#
+#    $ export QUERY_STRING='file=test.txt&key=Jazmin mini'; ./commentkey.cgi
+#
+# try using test file:
+# 
+#   root:/root> cat test.txt 
+#   [user]                       ; Jazmin mini-asterisk do not remove this comment
+#   host=sip.jazmin.net.au       ; Jazmin mini-asterisk do not remove this comment
+#   secret=<Password>            ; Jazmin mini-asterisk do not remove this comment           
+
+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"`
+key=`echo $QUERY_STRING | grep -oe "key=[^&?]*" | sed -n "s/key=//p" | sed "s/%22/\"/g"`
+echo $QUERY_STRING
+echo $file
+echo $key
+if [ -f $file ]; then
+  # to debug remove -i (write results to file), it will then just print results
+  perl -i -pe "s/(.*$key)/;\$1/" $file
+else
+  echo "$file does not exist"
+fi
+cat <<EOF
+</body>
+</html>
+EOF
index 773207d2e555e78fcbd97aee27c5a584c0e05174..2d49f0821dd7d0b409f61493cd33459d8de115f9 100755 (executable)
@@ -37,7 +37,7 @@ echo $that
 echo $key
 if [ -f $file ]; then
   # to debug remove -i (write results to file), it will then just print results
-  perl -pe "s/($this)[A-Za-z0-9\.\<\>]*(.*$key.*)/$this$that\$2/" $file
+  perl -i -pe "s/($this)[A-Za-z0-9\.\<\>]*(.*$key.*)/$this$that\$2/" $file
 else
   echo "$file does not exist"
 fi
diff --git a/mini-asterisk-gui2/cgi-bin/uncommentkey.cgi b/mini-asterisk-gui2/cgi-bin/uncommentkey.cgi
new file mode 100755 (executable)
index 0000000..2348dcf
--- /dev/null
@@ -0,0 +1,44 @@
+#!/bin/sh 
+# uncommentkey.cgi
+# David Rowe 30 Oct 2012
+#
+# CGI to uncomment a chunk of text that has a certain key phrase on each line
+#
+# Test on host with:
+#
+#    $ export QUERY_STRING='file=test.txt&key=Jazmin mini'; ./uncommentkey.cgi
+#
+# try using test file:
+# 
+#   root:/root> cat test.txt 
+#   ;[user]                       ; Jazmin mini-asterisk do not remove this comment
+#   ;host=sip.jazmin.net.au       ; Jazmin mini-asterisk do not remove this comment
+#   ;secret=<Password>            ; Jazmin mini-asterisk do not remove this comment           
+
+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"`
+key=`echo $QUERY_STRING | grep -oe "key=[^&?]*" | sed -n "s/key=//p" | sed "s/%22/\"/g"`
+echo $QUERY_STRING
+echo $file
+echo $key
+if [ -f $file ]; then
+  # to debug remove -i (write results to file), it will then just print results
+  perl -i -pe "s/^;(.*$key)/\$1/" $file
+else
+  echo "$file does not exist"
+fi
+cat <<EOF
+</body>
+</html>
+EOF