Delete Files with CGI Bash Script

Hi. I could use some help with my problem. I am creating a website. One option on this website is to delete a specified file, say an image, when the user clicks on it. I want to do this with CGI. I believe bash will be the easiest since I will just type the command "rm file". I also do not know Perl. I am, however, having trouble doing any file manipulation with my cgi-script. I did chmod 777 in case that was the problem. The HTML output works fine, the command "mkdir /testcgi" is not executed. Well, the directory testcgi is not created after going to the file online. The cgi file was created with sudo, not sure if that makes a difference.

#!/bin/bash
echo "Content-type: text/html"
echo ""

mkdir /test
mkdir /home/crimsonsecurity/testt

# our html code
echo "<html>"
echo "<head><title>Hello CGI</title></head>"
echo "<body>"
echo "<pre>"

# print out the environment settings
/usr/bin/env

echo "</pre>"
echo "</body>"
echo "</html>"

Are you sure its not a permissions issue ?
Most web servers "chroot" to the main documents area, and therefore your paths may be incorrect, or indeed you may not have permission to alter directories or files. I would start easy and try a "touch foo" and see if the file is created in the cgi-bin or doc areas on the web server.

I would also capture the stderr to see if there is any error message:

touch foo 2>&1

Thanks for the quick reply. This is the error I got with touch: "touch: cannot touch `foo': Permission denied." I added "grep da * 2> grep-errors.txt" to capture the stderr 2 output. I am the server admin as this is for my school project.

-Thanks

Edit: Link to my script: http://crimsonsecurity.dyndns.org/cgi-bin/del.cgi

I set the permissions on the directory that I need to delete files in to 777 with "chmod -R 777 /folder." I was able to create a directory where I needed to. All I need to do is delete files from this script. What is the most secure way to do this? Reading man chmod, I need to set only the write bit for all users, or just for www? Is that true?

I would try running an "id" within the script to see what userid and groups the cgi is running as. Once you know that, you can either "chown" or "chgrp" the directory and just give specific user rights, or if you cant do that, you can figure out what the minimum rights are.

After more time than it should have taken I have figured it out. It was a permission error which I used "chgrp" to correct.

Thanks for your help!