From bfb0cf34b6f9b687734c667f84d0dbe4c307d9a2 Mon Sep 17 00:00:00 2001 From: drowe67 Date: Mon, 29 Oct 2012 03:23:12 +0000 Subject: [PATCH] prototype version git-svn-id: https://svn.code.sf.net/p/freetel/code@887 01035d8c-6547-0410-b346-abe4f91aad63 --- mini-asterisk-gui2/cgi-bin/setlinekey2.cgi | 42 ++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100755 mini-asterisk-gui2/cgi-bin/setlinekey2.cgi diff --git a/mini-asterisk-gui2/cgi-bin/setlinekey2.cgi b/mini-asterisk-gui2/cgi-bin/setlinekey2.cgi new file mode 100755 index 00000000..673f8760 --- /dev/null +++ b/mini-asterisk-gui2/cgi-bin/setlinekey2.cgi @@ -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 + +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 -- 2.25.1