Jump to content


  • Content Count

  • Joined

  • Last visited

Posts posted by oneoleguy

  1. Hi Everyone,Continuing with my Perl learning process, the first program that is provided in most tutorials and manuals is the simple print statement. Like this:

    #!/usr/bin/perlprint "Hello, world";

    Well super this works on MS/DOS windows, raw Unix and Linux. I don't know about PerlMac, but I suspect that it does. However, I quickly found that this program won't run on Apache under Linux or Unix Servers. Even when the Apache Server is on your own PC.The reason for this is that you are operating in an Internet/browser environment. You need to modify your program to something like:

    #!/usr/perl/bin/print "Content-type: text/html\n\n";print "Hello, world";

    The Perl program now prints to your browser in an HTML format.Bill

  2. Hi everyone,I am starting to learn Perl and have had a little difficulty. The start of my problem was the Shebang line.It's the first line of a Perl program and starts out with #!. The # indicates a comment, but the following ! turns it into a perl directive. It is followed by /usr/bin/perl .The line would look like:


    Great, this is fine! It will work in Perl in MS/DOS windows, PerlMac, raw Unix (and Linux) and Apache servers on Unix (and Linux)However, when you run it on Apache on your own PC, you may have to change this line.I have Apache2Triad installed on my PC. The correct Shebang line for it is:


    This path to Perl is listed in the apache2triad Control Program, on the lower left of the screen. If you're just starting out with perl and your programs aren't working, check this line out, for "your server" first!Bill

    PS I have a 1999 copy of SAMS Teach Yourself Perl and it mentions that you may already have Perl installed on your PC. You may not need to install it. Get to a DOS prompt and type "Perl -v". If you get a PROGRAM NOT FOUND message, then it isn't installed. Get to a command prompt for unix and linux and type "perl -v" PerlMac is a little different - check your documentation.
  3. We're getting a lot of questions like this lately. It'd be nice <cough> if SOMEONE could pin us to a set of start-'em-ups for running (U)(Li)nux on a PC. It's just frustrating we can't paste a URL, you know?
    Let's see if I can start one, look for my post "The Perl Shebang line"Bill
  4. Well I think I've found my apache2triad server problem. It is 2 fold.1) the shebang line needs to look like this:


    and 2) the file extension must be .cgi.When I made these changes, the script worked fine on my apache2triad installation.Thanks for all your help,Bill

  5. Hi guys,I've been trying to get this programs to work and have part of my troubles figured out. The program:

    #!/usr/bin/perl 				  print "Hello, world";

    Didn't work on my apache2triad installation nor did it work on either of my domain hosts (both running linux/apache). I got a different tutorial and found this program:

    #!/usr/bin/perl -w				  print "Content-type: text/html\n\n";print "Hello, world";

    It did work on my domain hosts servers. It did not work on my apache2triad server.I think the apache2triad (perl portion) has some installation issues!I'm trying to register with the apache2triad forum to ask what the problem is.I'll let you know.Bill

  6. I believe Perl ignores the shebang (#!/path/to/perl) when a file is invoked from the command line, so that's no hint at all.Did you check the file permissions? You don't say. A file does not transmit, zipped or otherwise, with permissions. They must be reset.Try this shebang: /usr/local/bin/perlCould be your apache config file is not set up correctly.
    If the shebang is ignored at the command line and the program works, but the shebang isn't ignored in apache and the program doesn't run give a clue that it is the problem.I don't know how to check the permissions on this installation of apache2triad. All the domains I have are on linux (not win2000 like this installation) and they have a file manager from which to change the file permissions. I haven't been able to find one on this apache2triad installation.That shebang didn't work either.I don't know where the apache configuration file is either.Oh, yeah, I'm a real novice at this stuff.Bill
  7. W3Schools != W3C (World Wide Web Consortium)There is no relation. Why are so many people mistaken? Must be why W3Schools is so popular :)
    I want to change my original question from: How about that PHP Tutorial on the W3C site?to: How about the PHP Tutorial on this site?Bill
  8. I found another script and tested it as well.It got the same 500 error message under apache.It worked fine in a dos window with the command: perl fstprgm.pl (and .cgi)

    #!/usr/bin/perlprint "Hello, World...\n";

    Interesting!I am using a text editor (not notepad) named EditPlus. I use it for all my programming and all my scripts have always worked fine.The frstprgm.pl that ran in DOS/Win2000 worked fine but did not run when executed from apache. That kinda' makes me think that something in Apache isn't set-up correctly.Does it have a .ini file?Bill

  9. I got the script from an online website. It came in a .zip file. I unzipped it and copied it to another directory.I got a similar file on php called: phpinfo.php.The entire content of that file was: <?php phpinfo(); ?> I saw this perlinfo file and thought I'd be getting something similar.I guess I'll just wait until I start studying Perl to see all that Perl has on my PC.Thanks,Bill

  10. O.K. we're getting somewhere.I am just learning PHP. I don't need to be able to create perfect programs right now.What I'm doing is reading the manual and testing the code snippets in the manual. I DO like to see vertical printing as apposed to the horizontal printing I was getting.I will look into the tutorials in the forum.Bill

  11. I'm beginning to believe that I need a remedial course in PHP. The Manual may be too advanced for me.How about that PHP Tutorial on the W3C site?A part of the problem may also be that I'm not too proficient in HTML either.Bill

  12. Hello I was browsing today and found a site that provided a Perl Info script. When I tried it on my installation of Apache2Triad it didn't work. My guess is that I put it in the wrong directory, but I don't know the correct directory to put it in. I put it in apache2triad\htdocs.This is the script: perlinfo.cgi

    #!/usr/bin/perlprint "Content-type: text/html\n\n";#Location of Perl$output = `whereis perl`;@locations = split(" ",$output);foreach $line (@locations) 	{	$whereperl .= "$line<br>";	}#Location of Sendmail$output = `whereis sendmail`;@locations = split(" ",$output);foreach $line (@locations) 	{	$wheresendmail .= "$line<br>";	}#Location of Current Directory$currentdirectory = `pwd`;#Perl Variables$perlversion = $];#Perl Os$perlos = $^O;#Module Pathsforeach $line (@INC) 	{	$modulepaths .= "$line<br>";	}#Environment Variables$environment = qq~<table width="100%" border="1" cellspacing="0" cellpadding="2" bordercolor="#000000"><tr> <td colspan="2" bgcolor="#0033CC"> <div align="center" class="tabletitle">Environment Variables</div></td></tr>~;@allkeys = keys(%ENV);foreach  $key (@allkeys) {$value = $ENV{$key};if ($value eq "") {$value = "-";}$environment .= qq~<tr> <td width="150" class="tableitems">$key</td><td class="tablevalue">$value</td></tr>~;}$environment .= qq~</table>~;$documentroot = $ENV{'DOCUMENT_ROOT'};if ($documentroot ne ""){@lines = `du -c -k $documentroot`;$lastline = @lines-1;($diskusage) = split/[\t| ]/,$lines[$lastline];}#Server Software$serverip = $ENV{'SERVER_ADDR'};$servername = $ENV{'SERVER_NAME'};$serverport = $ENV{'SERVER_PORT'};$serversoftware = $ENV{'SERVER_SOFTWARE'};$serveruptime =`uptime`;#Localtime($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time);@months = ("Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec");$date = sprintf("%02d-%s-%04d",$mday,$months[$mon],$year+1900);$time = sprintf("%02d:%02d:%02d",$hour,$min,$sec);$localtime = "$date, $time";#GMTtime($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = gmtime(time);@months = ("Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec");$date = sprintf("%02d-%s-%04d",$mday,$months[$mon],$year+1900);$time = sprintf("%02d:%02d:%02d",$hour,$min,$sec);$gmttime = "$date, $time";print qq~<html><head><title>Perlonline.com - Perlinfo.cgi</title><meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"><style type="text/css"><!--.tabletitle {  font-family: Arial, Helvetica, sans-serif; font-size: 14px; font-weight: bold; background-position: center; color: #FFFFFF}.tableitems {  font-family: Arial, Helvetica, sans-serif; font-size: 12px}.tablevalue {  font-family: Arial, Helvetica, sans-serif; font-size: 12px; font-weight: bolder}--></style></head><body bgcolor="#FFFFFF" text="#000000"><table width="100%" border="1" cellpadding="2" cellspacing="0" bordercolor="#000000">  <tr bgcolor="#0033CC"> 	<td colspan="2" class="tabletitle"> 	  <div align="center">Server Information</div>	</td>  </tr>  <tr> 	<td class="tableitems" width="150" valign="top">Name</td>	<td class="tablevalue">$servername</td>  </tr>  <tr> 	<td class="tableitems" width="150" valign="top">IP</td>	<td class="tablevalue">$serverip</td>  </tr>  <tr> 	<td class="tableitems" width="150" valign="top">Listing Port</td>	<td class="tablevalue">$serverport</td>  </tr>  <tr> 	<td class="tableitems" width="150" valign="top">Document Root</td>	<td class="tablevalue">$documentroot</td>  </tr>  <tr>	<td class="tableitems" width="150" valign="top">Disk Usage by Root</td>	<td class="tablevalue">$diskusage Kb</td>  </tr>  <tr> 	<td class="tableitems" width="150" valign="top">Software's Installed</td>	<td class="tablevalue">$serversoftware</td>  </tr></table><br><table width="100%" border="1" cellspacing="0" cellpadding="2" bordercolor="#000000">  <tr bgcolor="#0033CC"> 	<td colspan="2" class="tabletitle"> 	  <div align="center">Perl Information</div>	</td>  </tr>  <tr> 	<td class="tableitems" width="150" valign="top">Perl version</td>	<td class="tablevalue">$perlversion</td>  </tr>  <tr> 	<td class="tableitems" width="150" valign="top">Compiled For</td>	<td class="tablevalue">$perlos</td>  </tr>  <tr> 	<td class="tableitems" width="150" valign="top">Module Paths</td>	<td class="tablevalue">$modulepaths</td>  </tr></table><br><table width="100%" border="1" bordercolor="#000000" cellpadding="2" cellspacing="0">  <tr bgcolor="#0033CC"> 	<td colspan="2" class="tabletitle"> 	  <div align="center">Location of Important Unix Programs</div>	</td>  </tr>  <tr> 	<td class="tableitems" width="150" valign="top">Perl</td>	<td class="tablevalue">$whereperl</td>  </tr>  <tr> 	<td class="tableitems" width="150" valign="top">Sendmail</td>	<td class="tablevalue">$wheresendmail</td>  </tr></table><br><table width="100%" border="1" cellspacing="0" cellpadding="2" bordercolor="#000000">  <tr bgcolor="#0033CC"> 	<td colspan="2" class="tabletitle"> 	  <div align="center">Time</div>	</td>  </tr>  <tr> 	<td class="tableitems" width="150" valign="top">Server Time (Local)</td>	<td class="tablevalue">$localtime</td>  </tr>  <tr> 	<td class="tableitems" width="150" valign="top">Server Time (GMT)</td>	<td class="tablevalue">$gmttime</td>  </tr></table><br>$environment <p align="center" class="tablevalue"> </p><p align="center" class="tablevalue">All rights Reserved 2001. <a href="http://www.perlonline.biz">Perlonline.biz</a></p></body></html>~;

    The error message I got was 500. My Command Panel says the path to perl is C:/apache2triad/perl/bin/perl.exe, if that makes any difference.Does anyone know what I'm doing wrong?Bill

  13. thats strange, gues somehow theres some weird char tat cant be shown in plain textremove the header that i said, and replace it byecho "<pre>";
    Great Wander,That worked perfectly!Thanks,Bill
  14. browsers use text/html as default content typetry addingheader('Content-type: text/plain');at the top of the page (after the <?php tag
    Wander,Thanks for your suggestion. It did and didn't work.It prompted a File Download critical message, but then when I accepted the download the output received was like the comment in the example said it should be.What next?Bill
  15. Here is an example of the problem, forgive me for not including it in my original post:

    <?php	   define('EPSILON', 1.0e-8);	   function real_cmp($r1, $r2)	   {			   $diff = $r1 - $r2;			   if( abs($diff) < EPSILON )					   return 0;			   else					   return $diff < 0 ? -1 : 1;	   }	   function real_lt($r1, $r2)	   {			   return real_cmp($r1, $r2) < 0;	   }	   echo "raw compare\n";	   $n = 0;	   for($i = 0.1; $i < 1.0; $i += 0.1) {			   $n++;			   echo "$i\t$n\n";	   }	   echo "\nepsilon compare\n";	   $n = 0;	   for($i = 0.1; real_lt($i, 1.0); $i += 0.1) {			   $n++;			   echo "$i\t$n\n";	   }/*	   Outputs:	   raw compare	   0.1	 1	   0.2	 2	   0.3	 3	   0.4	 4	   0.5	 5	   0.6	 6	   0.7	 7	   0.8	 8	   0.9	 9	   1	   10	   epsilon compare	   0.1	 1	   0.2	 2	   0.3	 3	   0.4	 4	   0.5	 5	   0.6	 6	   0.7	 7	   0.8	 8	   0.9	 9*/?>

    This is the output I am getting:raw compare 0.1 1 0.2 2 0.3 3 0.4 4 0.5 5 0.6 6 0.7 7 0.8 8 0.9 9 1 10 epsilon compare 0.1 1 0.2 2 0.3 3 0.4 4 0.5 5 0.6 6 0.7 7 0.8 8 0.9 9 The comment in this example suggests that each raw or epsilon and compare numbers combinations should be on a seperate line.They aren't. Do you know why?Bill

  16. Hi,I have Apache2Triad installed on my PC and I'm trying to learn PHP with the PHP manual.I've copied several examples into .php files and run them in Apache.The new line command "\n" doesn't produce a new line. I've looked through the php.ini file to see if I need to set a directive, but have been unable to find it.Could someone help direct me to a resolution of this issue?Bill

  17. I used that password to get into the ftp administrator: phpsftpd. Now all I need to know is how to use it!Anyway, the issue with the PHP files is resolved... It's my hosts issue.Further discussion of Apache should be done elsewhere.I thank each of you for helping me find the answers I needed.Have a nice day,One Ole Guy

  18. boen_robot,ftp requires a username and password, phpmyadmin requires a username and password, phppfstd requires a Login (what ever that is), phpxmail requires a username and password, uebimiau.webmail require a username and password.There are probably other areas of the Apache2Triad installation that I haven't explored yet that need username and password. Some, like the phpxmail may require me to set up accounts and I don't know how to do that.I know that MySql is part of the installation and haven't figured out where the Admin and/or tutorial areas are. It's a huge package. The installation excecutable was 98 MegaBites BIG. The installation program was looking for at least 248 MB of free storage space to install the software in. There's more than Apache here.So I do need a little assistance.Thanks,One Old Guy

  19. O.K. Now I know something.I'm not real sure what that is, but the forms generator application I've been having troubles with; worked perfectly fine with my new Apache Server on my PC.I haven't a clue what the PHP.ini file contains, but the application ran every program without error.I think this must mean that the reason it didn't run on my Hosts Server is because of some change they've made to this .ini file?Does that sound correct?One Ole Guy

  • Create New...