PowWeb Forums - The Perfect Community for the Perfect Host  

Register now to interact with over 11,000 members! Registered users have Posting Privileges, free access to Private Messaging, Email Notifications and more.

Go Back   PowWeb Community Forums > The PowWeb Platform > Perl
User Name
Password
Register FAQ Members List Search Today's Posts Mark Forums Read

Closed Thread
 
Thread Tools
Old 1-24-02, 07:38 PM   #1
Jami
 
Jami's Avatar
 
Join Date: Jan 2002
Posts: 223
Reputation: 53
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?
Jami is offline  
Old 1-24-02, 10:24 PM   #2
SaysMe
Guest
 
Posts: n/a
Try setting your text file to 644 or 664

~nan
 
Old 1-24-02, 11:24 PM   #3
SimCoWeb
 
SimCoWeb's Avatar
 
Join Date: Nov 2001
Location: CA
Posts: 3,874
Reputation: 6
Yep, need to make the .txt file writable. Either 766 or 777.
SimCoWeb is offline  
Old 1-24-02, 11:31 PM   #4
SaysMe
Guest
 
Posts: n/a
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.
 
Old 1-25-02, 12:28 AM   #5
Jami
 
Jami's Avatar
 
Join Date: Jan 2002
Posts: 223
Reputation: 53
CMOD

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?
Jami is offline  
Old 1-25-02, 12:36 AM   #6
SaysMe
Guest
 
Posts: n/a
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.
 
Old 1-25-02, 02:57 PM   #7
Jami
 
Jami's Avatar
 
Join Date: Jan 2002
Posts: 223
Reputation: 53
Good news and Bad news

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?
Jami is offline  
Old 1-25-02, 03:07 PM   #8
SimCoWeb
 
SimCoWeb's Avatar
 
Join Date: Nov 2001
Location: CA
Posts: 3,874
Reputation: 6
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:

www/g/gcm345/htdocs/data/orders.txt

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 So I use 777 instead. All lucky numbers
SimCoWeb is offline  
Old 1-25-02, 11:22 PM   #9
SaysMe
Guest
 
Posts: n/a
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 So I use 777 instead. All lucky numbers <<

Heh.... good one.

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? ;-)
 
Closed Thread

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 03:44 AM.


Contents ©PowWeb, Inc. ~ vBulletin, Copyright © 2000-2007 Jelsoft Enterprises Limited.