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. <br /><br />When i run the following script<br /><!--c1--><div class='codetop'>CODE</div><div class='codemain'><!--ec1-->#!/usr/bin/perl<br />print "hello, World!\n";<!--c2--></div><!--ec2--><br />i get this on my error log. <br />[2004-11-08 00:01:03]: error: file is writable by others: (/home/section3/public_html/cgi-bin/test.cgi)<!--content-->
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.<br /><br />^^^ shouldn't post until after her first cup of orange juice.<!--content-->
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 <img src="http://www.totalchoicehosting.com/forums/style_emoticons/default/smile.gif" style="vertical-align:middle" emoid="" border="0" alt="smile.gif" /><!--content-->
nope, I should've put this on my first post. I tried changing the permissions...that wasn't the prob.<!--content-->
Hmmm...... that's odd... I have no clue as to why it's complaining about that <img src="http://www.totalchoicehosting.com/forums/style_emoticons/default/huh.gif" style="vertical-align:middle" emoid=":huh:" border="0" alt="huh.gif" /><br />I tried searching Google about it and it came up with this interesting result:<br /><a href="http://www.webhostingtalk.com/archive/thread/74384-1.html" target="_blank">http://www.webhostingtalk.com/archive/thread/74384-1.html</a><br /><br />Try the suggestions they gave the other guy, maybe they work for you.<!--content-->
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.<br /><br /><!--quoteo--><div class='quotetop'>QUOTE</div><div class='quotemain'><!--quotec--><!--coloro:blue--><span style="color:blue"><!--/coloro-->#!/usr/bin/perl -w<br /><br />print "Content-type: text/html\n\n";<br />print "<html><head><title>Hello World!! </title></head>\n";<br />print "<body><h1>Hello world</h1></body></html>\n";<br /><!--colorc--></span><!--/colorc--><!--QuoteEnd--></div><!--QuoteEEnd--><!--content-->
ahhhh...i figured out the problem..<br /><br />It appears I needed to add this header...otherwise it will return a 500 error. <br /><br /><!--sizeo:14--><span style="font-size:12pt;line-height:100%"><!--/sizeo-->print "Content-type: text/html\n\n";<!--sizec--></span><!--/sizec--><br /><br />thanks rick...<!--content-->
Rick, I don't know much about PERL (actually, I know near nothing about PERL <img src="http://www.totalchoicehosting.com/forums/style_emoticons/default/tongue.gif" style="vertical-align:middle" emoid="" border="0" alt="tongue.gif" />) 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? <img src="http://www.totalchoicehosting.com/forums/style_emoticons/default/unsure.gif" style="vertical-align:middle" emoid=":unsure:" border="0" alt="unsure.gif" /><!--content-->
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.<!--content-->
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 <img src="http://www.totalchoicehosting.com/forums/style_emoticons/default/huh.gif" style="vertical-align:middle" emoid=":huh:" border="0" alt="huh.gif" /><br /><br />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 <img src="http://www.totalchoicehosting.com/forums/style_emoticons/default/huh.gif" style="vertical-align:middle" emoid=":huh:" border="0" alt="huh.gif" /><br /><br />Can one of the Perl coders from the family shed some light on my questions, please? <img src="http://www.totalchoicehosting.com/forums/style_emoticons/default/smile.gif" style="vertical-align:middle" emoid="" border="0" alt="smile.gif" /><!--content-->
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.<br /><br />^^^ shouldn't post until after her first cup of orange juice.<!--content-->
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 <img src="http://www.totalchoicehosting.com/forums/style_emoticons/default/smile.gif" style="vertical-align:middle" emoid="" border="0" alt="smile.gif" /><!--content-->
nope, I should've put this on my first post. I tried changing the permissions...that wasn't the prob.<!--content-->
Hmmm...... that's odd... I have no clue as to why it's complaining about that <img src="http://www.totalchoicehosting.com/forums/style_emoticons/default/huh.gif" style="vertical-align:middle" emoid=":huh:" border="0" alt="huh.gif" /><br />I tried searching Google about it and it came up with this interesting result:<br /><a href="http://www.webhostingtalk.com/archive/thread/74384-1.html" target="_blank">http://www.webhostingtalk.com/archive/thread/74384-1.html</a><br /><br />Try the suggestions they gave the other guy, maybe they work for you.<!--content-->
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.<br /><br /><!--quoteo--><div class='quotetop'>QUOTE</div><div class='quotemain'><!--quotec--><!--coloro:blue--><span style="color:blue"><!--/coloro-->#!/usr/bin/perl -w<br /><br />print "Content-type: text/html\n\n";<br />print "<html><head><title>Hello World!! </title></head>\n";<br />print "<body><h1>Hello world</h1></body></html>\n";<br /><!--colorc--></span><!--/colorc--><!--QuoteEnd--></div><!--QuoteEEnd--><!--content-->
ahhhh...i figured out the problem..<br /><br />It appears I needed to add this header...otherwise it will return a 500 error. <br /><br /><!--sizeo:14--><span style="font-size:12pt;line-height:100%"><!--/sizeo-->print "Content-type: text/html\n\n";<!--sizec--></span><!--/sizec--><br /><br />thanks rick...<!--content-->
Rick, I don't know much about PERL (actually, I know near nothing about PERL <img src="http://www.totalchoicehosting.com/forums/style_emoticons/default/tongue.gif" style="vertical-align:middle" emoid="" border="0" alt="tongue.gif" />) 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? <img src="http://www.totalchoicehosting.com/forums/style_emoticons/default/unsure.gif" style="vertical-align:middle" emoid=":unsure:" border="0" alt="unsure.gif" /><!--content-->
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.<!--content-->
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 <img src="http://www.totalchoicehosting.com/forums/style_emoticons/default/huh.gif" style="vertical-align:middle" emoid=":huh:" border="0" alt="huh.gif" /><br /><br />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 <img src="http://www.totalchoicehosting.com/forums/style_emoticons/default/huh.gif" style="vertical-align:middle" emoid=":huh:" border="0" alt="huh.gif" /><br /><br />Can one of the Perl coders from the family shed some light on my questions, please? <img src="http://www.totalchoicehosting.com/forums/style_emoticons/default/smile.gif" style="vertical-align:middle" emoid="" border="0" alt="smile.gif" /><!--content-->