-2

Can please anyone help me. i have the following script:

#!/bin/bash

cache_query=$QUERY_STRING
xxx=`echo $cache_query | grep -o 'x=[0-9]*' | sed 's/x=//g'`;  
yyy=`echo $cache_query | grep -o 'y=[0-9]*' | sed 's/y=//g'`;
zzz=`echo $cache_query | grep -o 'z=[0-9]*' | sed 's/z=//g'`; 
let "zzz=18-$zzz"   
content_type=`echo $cache_query | grep -o 'type_image=[a-z]*' | sed 's/type_image=//g'`;
db_name=`echo $cache_query | grep -o 'db=[a-z]*' | sed 's/db=//g'`;     


echo "Content-type: image/"${content_type}
echo ""


case "$db_name" in
"genshtab" ) db_path="/home/bases/gena.sqlite";;
"yasat"    ) db_path="/srv/ftp/upload/yasat.sqlitedb";;
esac


echo "x = " $xxx "y = " $yyy "z = " $zzz "type = " $content_type "database = " $db_name "db_path = " $db_path; #оставляю на всякий $
./tget ${db_path} ${db_name} "/mnt/tmpfs" ${content_type} ${zzz} ${yyy} ${xxx}
cat /mnt/tmpfs/${db_name}/${zzz}/${yyy}/${xxx}.${content_type}

i wrote tget program on c, so if i write

./tget /srv/ftp/upload/yasat.sqlitedb yasat /mnt/tmpfs png 17 0 1

in bash line everything go great, but if i try to call this program from bash script under apache http://46.182.21.31/?type_image=png&db=yasat&x=2&y=1&z=15 the program doesn't start and no errors in my log, is somebody have any ideas why?

  • 1
    Did you try giving the full path of tget to get it executed from bash script? – vijayalakshmi d Feb 22 '15 at 22:48
  • possible duplicate of [How to parse $QUERY\_STRING from a bash CGI script](http://stackoverflow.com/questions/3919755/how-to-parse-query-string-from-a-bash-cgi-script) – tripleee Feb 23 '15 at 08:48
  • Fix the query string parser and the [quoting](http://stackoverflow.com/questions/10067266/when-to-wrap-quotes-around-a-variable/27701642#27701642), then if you still cannot pull it off, try posting a new question with just the minimal case to reproduce your problem. See also http://stackoverflow.com/help/mcve – tripleee Feb 23 '15 at 08:52

1 Answers1

0

i was resolve a trouble the next way start c program with sudo sudo ./tget ...... and add to /etc/sudoers ability to user www-data to make sudo queries without password