Permission denied with PERL/APACHE

N

Nicolas D

Hello,

I use a PERLscript lauched by Apache web server,
with the line
"open (FICH, '>>commandes.txt') || die " error: :$!";

i obtain the following line in my error.log:
"permission denied

i tried to change the rights but with no results.

what is the pb ?

thanks
 
W

Walter Roberson

:I use a PERLscript lauched by Apache web server,
:with the line
:"open (FICH, '>>commandes.txt') || die " error: :$!";

:i obtain the following line in my error.log:
:"permission denied

:i tried to change the rights but with no results.

:what is the pb ?

Apache is not necessarily going to be "in" any directory that you
have write access to. Do not assume that just because your script
has been invoked, that the current working directory of the
executing script is anything even close to the location of the
script itself.

You should use chdir to change to the directory you need.


You also should not expect that Apache will be running under your
account id just because it launched your script. You might be able
to change the perl variable $> to the effective UID that you
want, but probably not -- Apache is not likely going to be running
as root.
 
T

Tad McClellan

I use a PERLscript lauched by Apache web server,


What is a "PERLscript"?

Did you mean "Perl script" or "Perlscript"instead?

with the line
"open (FICH, '>>commandes.txt') || die " error: :$!";

i obtain the following line in my error.log:
"permission denied

i tried to change the rights but with no results.

what is the pb ?
^^
^^

What is the Peanut Butter? Your question makes no sense to me...


Your problem is that you do not have the required permissions, what else?

You don't tell us what OS you are using, but if it is a *nix-flavor
one, you may need to change the permisssions on the directory that
the file is in, rather than the permissions on the file itself...
 
N

Nicolas D

Tad McClellan said:
What is a "PERLscript"?

Did you mean "Perl script" or "Perlscript"instead?


^^
^^

What is the Peanut Butter? Your question makes no sense to me...


Your problem is that you do not have the required permissions, what else?

You don't tell us what OS you are using, but if it is a *nix-flavor
one, you may need to change the permisssions on the directory that
the file is in, rather than the permissions on the file itself...

my OS is mandrake10 with "Apache-AdvancedExtranetServer/2.0.48
(Mandrake Linux/5mdk) mod_perl/1.99_11 Perl/v5.8.3 Server at 127.0.0.1
Port 80"

i write
"User apache
Group apache" in httpd2.conf,

the perl script is ok when i excecute it in the directory, i can write
in the file, but when i launch it with apache i obtain "permission
denied" when the script open the file with write access rights,
i create a login with apache user and apache group but no results,
i think my problem is that i don't know how configure apache to have
write rights....so i download the perl and apache documentation and i
ll read it.
Excuse for my english wich is as bad as my perl knowledge.
 
T

Tad McClellan

i think my problem is that i don't know how configure apache


Then you should be asking in a newsgroup that has something
to do with configuring web servers.

comp.lang.perl.misc is not such a newsgroup.

comp.infosystems.www.servers.unix is though.
 
G

gnari

Nicolas D said:
Your problem is that you do not have the required permissions, what else?

You don't tell us what OS you are using, but if it is a *nix-flavor
one, you may need to change the permisssions on the directory that
the file is in, rather than the permissions on the file itself...

my OS is mandrake10 with "Apache-AdvancedExtranetServer/2.0.48
(Mandrake Linux/5mdk) mod_perl/1.99_11 Perl/v5.8.3 Server at 127.0.0.1
Port 80"

i write
"User apache
Group apache" in httpd2.conf,

the perl script is ok when i excecute it in the directory, i can write
in the file, but when i launch it with apache i obtain "permission
denied" when the script open the file with write access rights,
i create a login with apache user and apache group but no results,
i think my problem is that i don't know how configure apache to have
write rights....so i download the perl and apache documentation and i
ll read it.
Excuse for my english wich is as bad as my perl knowledge.[/QUOTE]

then make sure to
a) make sure the writing happens in the directory you
think it does, by doing a chdir or changing the open to
my $fullpath='/fullpath/to/dir/commandes.txt';
open (FICH, ">> $fullpath")
|| die " error: could not open '$fullpath' :$!";
b) make sure that said directory is owner and/or writable
by user or group apache

gnari
 
W

Walter Roberson

:the perl script is ok when i excecute it in the directory, i can write
:in the file, but when i launch it with apache i obtain "permission
:denied" when the script open the file with write access rights,

Did you follow my advice to check out your $> and to not assume
that you are in any particular directory? Start by fully-qualifying
the path to your commands.txt file rather than assuming that you can
write in the current working directory.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,764
Messages
2,569,567
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top