section31 Posted November 8, 2004 Posted November 8, 2004 hm, I'm having trouble getting a basic perl script to run on my server. Anyone want to help me out. Never done this before. When i run the following script >#!/usr/bin/perl print "hello, World!\n"; i get this on my error log. [2004-11-08 00:01:03]: error: file is writable by others: (/home/section3/public_html/cgi-bin/test.cgi) Quote
LisaJill Posted November 8, 2004 Posted November 8, 2004 (edited) Try changing the permissions to either 755 or 666 or 644. I just woke up and can't remember how to work out which is right, but basically people can write to it which isn't right. ^^^ shouldn't post until after her first cup of orange juice. Edited November 8, 2004 by TCH-Lisa Quote
borfast Posted November 8, 2004 Posted November 8, 2004 755 allows everyone to read the file, only the owner can write to it and anyone can execute it, so that's probably what you're looking for Quote
section31 Posted November 8, 2004 Author Posted November 8, 2004 nope, I should've put this on my first post. I tried changing the permissions...that wasn't the prob. Quote
borfast Posted November 8, 2004 Posted November 8, 2004 Hmmm...... that's odd... I have no clue as to why it's complaining about that I tried searching Google about it and it came up with this interesting result: http://www.webhostingtalk.com/archive/thread/74384-1.html Try the suggestions they gave the other guy, maybe they work for you. Quote
TCH-Rick Posted November 8, 2004 Posted November 8, 2004 The permissions on the file and the folder should be set to 755 for perl scripts. They cannot be set to 777 or you will get the error given. The script you pasted will work fine in a shell but will not run through a browser. Here is a simple script that should run through a browser. #!/usr/bin/perl -w print "Content-type: text/html\n\n"; print "<html><head><title>Hello World!! </title></head>\n"; print "<body><h1>Hello world</h1></body></html>\n"; Quote
section31 Posted November 8, 2004 Author Posted November 8, 2004 ahhhh...i figured out the problem.. It appears I needed to add this header...otherwise it will return a 500 error. print "Content-type: text/html\n\n"; thanks rick... Quote
borfast Posted November 8, 2004 Posted November 8, 2004 Rick, I don't know much about PERL (actually, I know near nothing about PERL ) and I don't get it: why can't the script print "Hello World" without complaining about file permissions but then it can print headers to the browser without any problem? Quote
TCH-Rick Posted November 8, 2004 Posted November 8, 2004 I don't do a lot with perl either but I believe that you basically have to tell perl to send the output to an html header that can be seen in a browser rather than sent to the command line. The script I copied is one I found somewhere that is useful when we get tickets claiming that perl is "not working". If I run the original script from the command line it will work fine but trying to run it from a browser returns the error since the output is trying to go to the command line which is not allowed. Quote
borfast Posted November 9, 2004 Posted November 9, 2004 (edited) Hmmm... but in all those lines, you're always calling the exact same function: print. Does that function know whether it should print text to the stdout or via an HTTP connection based on what you tell it to write? That doesn't make much sense... I think From what I remember, the print function should always print to stdout but you (or the Perl interpreter, if needed or configured to do so) can redirect stdout to wherever you want. stdout is the "standard output", which means it will be whatever is more appropriate for the case you're in. For instance, in the old days, the standard output would be a line printer - in this case it's the HTTP connection to the browser. At least that's how it works with C/C++, if I recall correctly. I don't think Perl will be much different Can one of the Perl coders from the family shed some light on my questions, please? Edited November 9, 2004 by TCH-Raul Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.