Jump to content

oneoleguy

Members
  • Content count

    42
  • Joined

  • Last visited

Everything posted by oneoleguy

  1. oneoleguy

    Your first Perl Program

    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. oneoleguy

    The Perl Shebang Line

    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: #!/usr/bin/perl 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: #!C:/apache2triad/perl/bin/perl.exe 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
  3. oneoleguy

    Perl Info

    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
  4. oneoleguy

    Perl Info

    Let's see if I can start one, look for my post "The Perl Shebang line"Bill
  5. oneoleguy

    Perl Info

    Well I think I've found my apache2triad server problem. It is 2 fold.1) the shebang line needs to look like this: #!C:/apache2triad/perl/bin/perl.exe 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
  6. oneoleguy

    New Line not working!

    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
  7. oneoleguy

    Perl Info

    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
  8. oneoleguy

    New Line not working!

    Wow, I'm glad I asked!Thank you for the nformation.Bill
  9. oneoleguy

    Perl Info

    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
  10. oneoleguy

    New Line not working!

    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
  11. oneoleguy

    New Line not working!

    Have you looked at this site?http://www.w3schools.com/php/Bill
  12. oneoleguy

    Perl Info

    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
  13. oneoleguy

    Perl Info

    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
  14. oneoleguy

    New Line not working!

    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
  15. oneoleguy

    New Line not working!

    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
  16. oneoleguy

    New Line not working!

    Wander,I put that line in the other .php files that weren't printing with the new line and they do now.I've gotta' study that <pre> command.Bill
  17. oneoleguy

    New Line not working!

    Great Wander,That worked perfectly!Thanks,Bill
  18. oneoleguy

    New Line not working!

    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
  19. oneoleguy

    New Line not working!

    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
  20. oneoleguy

    $_POST

    Hello,I made an earlier post about an IF test and found that the $fields = $_POST['fields']; was missing.I have gotten a forms generating program and found that each program has bugs in them. I figured that someone got angry with the purveyors of the software and removed all the $_POST statements.I've been replacing them when I find them, but I have 2 that aren't fixed by simply placing a $variablename = $_POST['variablename']; in the PHP file.I begin to believe that defining a variable as being passed in a POST statement from another file may have different forms for different variable types.For instance $variablename = $_POST['variablename']; seems to work fine for a TEXT variable, but not for a Radio Button.I've looked in the PHP Tutorial but it doesn't go into this level of detail. I've searched 2 PHP Reference Manuals and have been unable to find adequate examples of the $_Post command.Could someone tell me the syntax for each of the variable types used in passing information from a POST statement in one program to another program?One Ole Guy
  21. oneoleguy

    $_POST

    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
  22. oneoleguy

    $_POST

    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
  23. oneoleguy

    $_POST

    Does anyone know where the default passwords are with this installation of Apache?I've looked, but without success.One Ole Guy
  24. oneoleguy

    $_POST

    I figured out why that hi! program didn't work. I named it hi.html, not hi.php.Somedays you feel like a nut, somedays you don't.One Ole guy
  25. oneoleguy

    $_POST

    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
×