Jump to content

oneoleguy

Members
  • Content count

    42
  • Joined

  • Last visited

Community Reputation

0 Neutral

About oneoleguy

  • Rank
    Newbie
  1. 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. 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. Perl Info

    Let's see if I can start one, look for my post "The Perl Shebang line"Bill
  4. 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
  5. 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
  6. New Line not working!

    Wow, I'm glad I asked!Thank you for the nformation.Bill
  7. 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
  8. 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
  9. New Line not working!

    Have you looked at this site?http://www.w3schools.com/php/Bill
  10. 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
  11. 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
  12. 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
  13. 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
  14. 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
  15. 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
×