create a new directory from cgi script

hello.
i hav accepted name of directory from user through a form.now i need to create a directory under cgi-bin of that name.I am not able to do so.n help is required

show us the relevant code with which you are trying to create the directory

what error do you see?

i hav taken directory name from form and passed it to subroutine.I checked if directory name accepeted is correct or not by printin it.its correct.$_[0]->is my directory name
i hav used two lines below:

my $dir="/var/www/cgi-bin/"."$_[0]";
my $r=system('mkdir -p -m 755 $dir');

Directory is not being created. It shows no errors!

try replacing this:

my $r=system('mkdir -p -m 755 $dir');

with this:

my $r=system("mkdir -p -m 755 $dir");

also, it would be good to (a) check the return status from the system call and (b) mention full path to mkdir

1.i changed single quotes to double quotes.It din work.
2.I checked return status.It is 256.
3.Full path i hav specified.It din work.

One more thing:
When i ran a sample perl cgi script from terminal it created a directory .But wen run from form it did not.

apache is running with previledges of what user? (for example, user named nobody) check:

ps -ef | grep httpd

does user running apache have write permission for the directory in which you are trying to create a subdirectory?

You may need to enable suexec to allow the script to create the directory. Suexec makes perl run as the user.

its running under root.

but i checked in error_log: the error msg is

mkdir: cannot create directory `image': Permission denied

how to i get permission to create a directory.i am logged in as root.

how do i enable suexec?

is thr no other way.I mean by using su or sudo?

Apache 2.0
suEXEC Support - Apache HTTP Server

Apache 1.3
Apache suEXEC Support

If the script is running as root, it should be able to do it, but if it's being called from a website, it won't be running as root.

i need help wIth respect to suexec,

Is there no way by which i can change permissions to that of root from within the cgi-script instead of suexec?