From a3081e944542991c6cfbf8d3afc55d4db35a819f Mon Sep 17 00:00:00 2001 From: horse69 Date: Sun, 28 Oct 2012 22:36:41 +0000 Subject: [PATCH] git-svn-id: https://svn.code.sf.net/p/freetel/code@862 01035d8c-6547-0410-b346-abe4f91aad63 --- mini-asterisk-gui2/cgi-bin/setword.cgi | 39 ++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 mini-asterisk-gui2/cgi-bin/setword.cgi diff --git a/mini-asterisk-gui2/cgi-bin/setword.cgi b/mini-asterisk-gui2/cgi-bin/setword.cgi new file mode 100644 index 00000000..3bb561e4 --- /dev/null +++ b/mini-asterisk-gui2/cgi-bin/setword.cgi @@ -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 + +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 -- 2.25.1