+ Reply to Thread
Page 1 of 2 12 LastLast
Results 1 to 10 of 13

Thread: Perl version on free host?

  1. #1
    jdw999's Avatar
    jdw999 is offline x10Hosting Member jdw999 is an unknown quantity at this point
    Join Date
    Jun 2008
    Posts
    45

    Question Perl version on free host?

    I posted this question in the free hosting forum, and evidently there are no Perl programmers online just now. Or something.

    Anyhow, I want to write some CGI scripts in Perl on my local machine for development before I upload to the X10 server. To get my local environment set up, I would like to find out what version of Perl is installed on absolut.

    CPanel used to display this info, but I don't see it--though the versions of MySQL and PHP are displayed. I can run a script that displays the server environment, but don't know enough to query for the Perl version, or even if that is possible.

    I have searched the forums and don't find any way to determine the version of Perl that is running on my host. Any clues?

  2. #2
    garrettroyce's Avatar
    garrettroyce is offline Generally Helpful Member garrettroyce is a glorious beacon of lightgarrettroyce is a glorious beacon of light
    Join Date
    Apr 2008
    Location
    IL, USA
    Posts
    3,746

    Re: Perl version on free host?

    I found the query but I don't know enough about perl to run it :P

    Code:
    #!/usr/bin/perl
    # Available under BSD License.
    # See url http://www.cyberciti.biz/faq/how-can-i-find-out-perl-version/
    $command=`perl -v`;
    $title = "Perl Version";
    
    print "Content-type: text/html\n\n";
    print "<html><head><title>$title</title></head><body>";
    
    print "<h1>$title</h1>\n";
    print $command;
    
    print "</body></html>";
    gjr.gr - coming soon: secrets of OCD coding from a self taught tinkerer

  3. #3
    jdw999's Avatar
    jdw999 is offline x10Hosting Member jdw999 is an unknown quantity at this point
    Join Date
    Jun 2008
    Posts
    45

    Re: Perl version on free host?

    Hey garrettroyce.

    I copied and pasted the code you found into a blank text file and saved it as "perlv.pl" in the cgi-bin dir of the apache server on my development box. I typed: "localhost/cgi-bin/perlv.pl" into the address bar and got the same message I get when I type "perl -v" on the command line...which makes perfect sense. lol

    So, I uploaded the script to my X10 cgi-bin directory and changed the permissions to 755, typed the address into the browser address window, and got a 500 error. I have several scripts that work, so it is not the path to perl, though it may be something else in the script.

    Or, it could be that X10 somehow blocks certain queries. Like you, I don't know enough to make a guess on that.

    For now, I am using ActivePerl (on Windows, cause ... I dunno; too much trouble to reboot to my Ubuntu partition all the time, i guess) 5.8.9 and I will see if I run into any problems.

  4. #4
    garrettroyce's Avatar
    garrettroyce is offline Generally Helpful Member garrettroyce is a glorious beacon of lightgarrettroyce is a glorious beacon of light
    Join Date
    Apr 2008
    Location
    IL, USA
    Posts
    3,746

    Re: Perl version on free host?

    Sorry I couldn't be more help :P

    I know in other programming languages you can check if a function exists, so if you find a function that only exists in a bleeding-edge version of perl, you can always check to make sure our version supports it:
    Code:
    pseudo-code:
    if function_exists("new_perl_function")  execute new_perl_function()
    else print 'ERROR: Function does not exist'
    Last edited by garrettroyce; 03-28-2009 at 04:12 PM.
    gjr.gr - coming soon: secrets of OCD coding from a self taught tinkerer

  5. #5
    jdw999's Avatar
    jdw999 is offline x10Hosting Member jdw999 is an unknown quantity at this point
    Join Date
    Jun 2008
    Posts
    45

    Re: Perl version on free host?

    Thanks garrett.

    Seems I read somewhere that we don't have shell access to the X10 environment. I wonder if that is why this script does not work. In other words, whether the server reads the script as somehow equivalent to using the command line.

  6. #6
    garrettroyce's Avatar
    garrettroyce is offline Generally Helpful Member garrettroyce is a glorious beacon of lightgarrettroyce is a glorious beacon of light
    Join Date
    Apr 2008
    Location
    IL, USA
    Posts
    3,746

    Re: Perl version on free host?

    Ah, makes sense.

    ok, I found this script, but I get a 500 error. Maybe you can get it to work:

    Code:
    #!/usr/bin/perl
    print "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 Paths
    foreach $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">&nbsp;</p>
    <p align="center" class="tablevalue">All rights Reserved 2001. <a href="http://www.perlonline.biz">Perlonline.biz</a></p>
    </body>
    </html>
    ~;
    Last edited by garrettroyce; 03-29-2009 at 12:10 PM.
    gjr.gr - coming soon: secrets of OCD coding from a self taught tinkerer

  7. #7
    misson is offline x10 Spammer misson is a jewel in the rough
    Join Date
    Mar 2008
    Location
    Libertatia
    Posts
    2,506

    Re: Perl version on free host?

    You can also use $] or $PERL_VERSION/$^V.
    Code:
    #!/usr/bin/env perl
    use CGI ':standard';
    
    print header('text/plain');
    printf "\$^V: v%vd\n",$^V;
    print '$]: ',int($]),'.',int(($]-int($]))*1000),'.', int(($]*1000 - int($]*1000))*1000), "\n";

  8. #8
    garrettroyce's Avatar
    garrettroyce is offline Generally Helpful Member garrettroyce is a glorious beacon of lightgarrettroyce is a glorious beacon of light
    Join Date
    Apr 2008
    Location
    IL, USA
    Posts
    3,746

    Re: Perl version on free host?

    I get a server error when using that script. I don't know if it's something I'm doing or if, like all the other scripts I've tried so far, it just doesn't work here at x10.
    gjr.gr - coming soon: secrets of OCD coding from a self taught tinkerer

  9. #9
    misson is offline x10 Spammer misson is a jewel in the rough
    Join Date
    Mar 2008
    Location
    Libertatia
    Posts
    2,506

    Re: Perl version on free host?

    Quote Originally Posted by garrettroyce View Post
    I get a server error when using that script. I don't know if it's something I'm doing or if, like all the other scripts I've tried so far, it just doesn't work here at x10.
    It works for me on Absolut (where it reports v5.8.. Anything interesting in your error log?

    Edit:
    1st script had a rounding error. Here's a fixed version:
    Code:
    #!/usr/bin/env perl
    use CGI ':standard';
    
    print header('text/plain');
    printf "\$^V: v%vd\n",$^V;
    print '$]: ',int($]),'.',int(($]-int($]))*1000),'.', int(($]*1000 - int($]*1000))*1000 + 0.5), " ($])\n";
    Last edited by misson; 03-30-2009 at 02:28 PM.

  10. #10
    alcramer is offline x10Hosting Member alcramer is an unknown quantity at this point
    Join Date
    Aug 2007
    Posts
    53

    Re: Perl version on free host?

    Hi--
    Don't know if this helps -- you may already have discovered this -- but x10hosting is a little funny about where they want you to upload your Perl scripts. A common practice is to put them in some
    subdirectory "cgi-bin" of your root public directory (by "root public directory" I just mean the directory in which your "index.html" is located). When I deployed my site on x10hosting (which worked fine under localhost Apache) I found that the scripts wouldn't run unless I moved them up to my root public directory. Then everything worked. It's like they want you to use a flat-directory structure.
    Also you may want to fiddle with file permissions. 755 vs. 777. Good luck!
    Al

+ Reply to Thread
Page 1 of 2 12 LastLast

Similar Threads

  1. Create your own free forum using x10Hosting
    By Gigacore in forum Tutorials
    Replies: 46
    Last Post: 12-01-2008, 03:07 PM
  2. X10 is the best free host, bar none!
    By revoman in forum Feedback and Suggestions
    Replies: 2
    Last Post: 11-13-2007, 01:08 AM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
x10hosting free hosting for the masses
dedicated servers