i'm trying call bash script within webpage page using cgi. have partially working in echo commands appear work other commands don't.
i'm using lighttpd , have file cgi.sh, calls demo_start.sh
cat /srv/http/cgi.sh
#!/bin/bash . includes/srv/http/demo_start.sh /usr/bin/bash /srv/http/demo_start.sh cat /srv/http/demo_start.sh
#!/bin/bash printf "content-type: text/plain\n\n" ip route 1 | awk '{print $nf;exit}'>/srv/http/ip.txt file="/srv/http/ip.txt" ip_address=$(cat ${file}) echo ${ip_address} file="/srv/http/demo_count.txt" count=$(cat ${file}) ((count++)) echo ${count} > ${file} echo demo started ${count} times sed -i".bak" '$d' /srv/http/index.html sed -i '$ <a href="http://'${ip_address}':'${count}'">start demo</a<br/>' /srv/http/index.html when access http://localhost/cgi.sh
172.27.103.31
demo started 8056 times
if refresh get
172.27.103.31
demo started 8057 times
all echo commands working , reads , write counter file correctly. sed commands not run index.html isn't updated.
if sh demo_start.sh bash prompt works correctly. how commands run when call script via cgi?
thanks in advance
Comments
Post a Comment