From: drowe67 Date: Tue, 30 Oct 2012 04:26:50 +0000 (+0000) Subject: added comment and uncomment scripts X-Git-Url: http://git.whiteaudio.com/gitweb/?a=commitdiff_plain;h=0b90264f48bfbd6807f0faf5b6b153eaa3733897;p=freetel-svn-tracking.git added comment and uncomment scripts git-svn-id: https://svn.code.sf.net/p/freetel/code@898 01035d8c-6547-0410-b346-abe4f91aad63 --- diff --git a/mini-asterisk-gui2/cgi-bin/commentkey.cgi b/mini-asterisk-gui2/cgi-bin/commentkey.cgi new file mode 100755 index 00000000..afaf43dc --- /dev/null +++ b/mini-asterisk-gui2/cgi-bin/commentkey.cgi @@ -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= ; Jazmin mini-asterisk do not remove this comment + +cat < + + + + + +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 diff --git a/mini-asterisk-gui2/cgi-bin/setlinekey2.cgi b/mini-asterisk-gui2/cgi-bin/setlinekey2.cgi index 773207d2..2d49f082 100755 --- a/mini-asterisk-gui2/cgi-bin/setlinekey2.cgi +++ b/mini-asterisk-gui2/cgi-bin/setlinekey2.cgi @@ -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 index 00000000..2348dcf6 --- /dev/null +++ b/mini-asterisk-gui2/cgi-bin/uncommentkey.cgi @@ -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= ; Jazmin mini-asterisk do not remove this comment + +cat < + + + + + +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