Click to See Complete Forum and Search --> : Please Help with My bash cgi script


mountianman
10-02-2003, 04:04 PM
Hello,
I am trying to write a cgi script in Bash to process some information then search for it. So far I can get the query_string and gawk out the variables that I want. Once I get the variables I try to search a folder wich I named Companys. There are 2 variables that I'm trying to input into the final command, but I think my syntax may be wrong. below is a copy of the script, I would be greatful for any help.

#!/bin/bash
echo "Content-Type: text/html"
echo ""
compname=$(echo $QUERY_STRING | gawk -F'&' '{print $1}' | gawk -F= '{print $2}')
lsdnum=$(echo $QUERY_STRING | gawk -F'&' '{print $2}' | gawk -F= '{print $2}')

result=$(find $lsdnum/var/www/cgi-bin/companys/$compname)
echo $result >> companys/search.txt


END SCRIPT

I testing everything, and I can write all the information to the search.txt file manually. But when I try to run the finaly 2 commands they information doesn't append into the file. Can you put variables directly into a command in the way that I did? Thanks.

Jay

Modorf
10-02-2003, 04:21 PM
what are the file and directory permisions? read / write / exicute?

I know that cgi scripts are usually run as user 'nobody' or 'ftp' to limit the risk of problems. the user that the cgi script is running as might not have enough permisions to write to the file.

N

mountianman
10-02-2003, 04:26 PM
Thanks for your reply. Yes I already tried setting full permissions for everyone to read/write/execute the file, but with no success. This is why i believe to problem to reside in my syntax, perhaps there is a different way of achieving the same goal?

mountianman
10-02-2003, 04:29 PM
Something else I might add, This version of the script works. Just to assure that permissions are correct.

#!/bin/bash
echo "Content-Type: text/html"
echo ""
compname=$(echo $QUERY_STRING | gawk -F'&' '{print $1}' | gawk -F= '{print $2}')
lsdnum=$(echo $QUERY_STRING | gawk -F'&' '{print $2}' | gawk -F= '{print $2}')

echo $compname >> companys/search.txt
echo $lsdnum >> companys/search.txt