View Full Version : Premature end of script headers error on a TEXT file
Okay guys, this has to have a simple answer *smile*
I am using php to open and append text to a text file in my cgi-bin, but I am getting the dreded -Premature end of script headers- on the txt file itself.
Yes, I uploaded the empty txt file in ASCII, with permissions 755 - do I have to have something, header wise, in the text file?
Try setting your text file to 644 or 664
1-25-02, 12:24 AM
Yep, need to make the .txt file writable. Either 766 or 777.
SimCo, is the higher permissions number a PHP-thing? What I know about PHP, you could fit on the fingernail of my pinky finger.
All the Perl scripts I've used (except one) require a 644/664 permission for text files... even the ones that are written to, so this is where I'm coming from. When I've tried higher numbers than that, they generally don't work.
When using WS_FTP LE I find that I cannot change the file permissions on just one file without all other files and the directory itself also changing to match. Is this a problem with the LE version, or is this only happening to me?
Anyone else heard of this type of problem?
The program shouldn't actually be changing all of the files in the directory, but when you select one of the other files, then right-click and select CHMOD, it will show you which permission you last used. Is that what you are looking at?
A better way to tell if it's actually changing permission is to click on the DirInfo button and look at the permissions file for a particular directory.
The good news is that I see that you are right about setting the file permissions using WS_ FTP and then checking them using DirInfo - Thanks
The bad news is even after I set the permissions to 777 on my txt file I still see this in my error log:
Premature end of script headers: /www/g/gcm345/cgi-bin/orders.txt
plus this on the page that opens when I run my php file:
Warning: fopen("http://www.garycarpenter.org/cgi-bin/orders.txt", "a") - Undefined error: 0
I have been told that fopen is having trouble opening my orders.txt file because of permissions too, but this can't be true when I set the permissions to 777.
Any other ideas?
1-25-02, 04:07 PM
Jami , try moving the text file 'outside' the cgi-bin. Perhaps make a folder for it under your /htdocs directory called 'data' and point the path in the script to the file there like this:
Then, set permissions on the /data folder and the .txt file to 777. Let's see what happens.
Saysme , in regards to the PHP permissions, the only files that need chmod (normally) are the ones called directly from the browser (ex: index.php). They should have chmod to 755 and have the #!/usr/local/bin/php line at the top of the script page for each one called directly.
For other 'writeable files' as you asked above, I find that 666 can work. The problem is, it's the sign of the devil and reminds me of my ex :D So I use 777 instead. All lucky numbers ;)
Originally posted by SimCoWeb:
>>Saysme, in regards to the PHP permissions, the only files that need chmod (normally) are the ones called directly from the browser (ex: index.php). They should have chmod to 755 and have the #!/usr/local/bin/php line at the top of the script page for each one called directly.<<
Ah, okay... thanks.
>>For other 'writeable files' as you asked above, I find that 666 can work. The problem is, it's the sign of the devil and reminds me of my ex :D So I use 777 instead. All lucky numbers ;)<<
Heh.... good one. :D
Many of the Perl scripts I've got are specific about calling for a 644, 664, or 666 (lower, the better for security.... but whatever you can get to work for you). On these scripts, if I blow it and accidently change them to 755/777, they don't work at all until I change them to the sixes. So.... that's where I was coming from. Fun stuff, huh? ;-)
vBulletin® v3.8.7, Copyright ©2000-2013, vBulletin Solutions, Inc.