Gossamer Forum
Home : General : Perl Programming :

Cannot open files created by CGI script

Quote Reply
Cannot open files created by CGI script
This is quite an annoyance and I hope someone can shed some light on this problem (I have no doubt about it...Smile)

I wrote a script to automate the creation of some HTML files based on data submitted from a form. This is to ease the burden on my web team since there would be many files to create manually.

The script works beautifully and all the generated files are viewable via the browser.

The only catch is that I cannot open the files as a user in order to modify them (but I can still delete them).

I have tried doing a chmod 0755 in the script but that does not seem to work.

I think the basic problem is due to the fact that these files are created by a cgi script but I can't see why that should prevent the change of permissions...

Help...

Thanks

Last edited by:

Crolguvar: Jan 12, 2004, 7:58 AM
Quote Reply
Re: [Crolguvar] Cannot open files created by CGI script In reply to
Who 'owns' the generated files? Some servers don't use things like SuEXEC, which causes files to be owned by users like 'root' and 'nobody'. If a file is set to 'nobody', then on most systems these files will not be viewable/editable by the domain user.

Cheers

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Quote Reply
Re: [Andy] Cannot open files created by CGI script In reply to
I believe the owner is Apache (the Web server in use for this site). Would that be the reason why the chmod command gets ignored?

Thanks.
Quote Reply
Re: [Crolguvar] Cannot open files created by CGI script In reply to
If the CHMOD command is being run by the script, i.e;

Code:
open(FILEWRITE, ">test.txt") || die "Error: Couldn't write test.txt. Reason: $!";
print FILEWRITE "testing";
close(FILEWRITE);

chmod(0777,'test.txt');

Then that should CHMOD the file to 777. I would imagine if you try and do it through a FTP client though, it just gives you a 'permission denied' error, right?

Cheers

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Quote Reply
Re: [Andy] Cannot open files created by CGI script In reply to
Pretty much. That's how I change the file permissions in the script.

The script itself FTPs the files to another server. Through an FTP client (such as WS_FTP Pro) I cannot view or send the files from the server on which they were generated, I get a permission denied. However on the remote server where the script sends the files, I can view them with the FTP client.

Our setup is a litle complicated. The web server where this site is located runs on Solaris. My workstation is Win2k Blush so I use a Samba mapping to view the folders on Solaris. I can't see the Unix-like permissions for those files through the mappingMad.

Samba does attempts to translate them to something Windows would understand and that gives indicates Apache and Everyone have all permissions.

Actually it looks like there is an Everyone group with full access, an apache user with full access and an apache group with no permissions at all...