<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>ServerAdmins.NET &#187; Perl</title>
	<atom:link href="http://serveradmins.net/tag/perl/feed/" rel="self" type="application/rss+xml" />
	<link>http://serveradmins.net</link>
	<description>Stuff for Server Admins...</description>
	<lastBuildDate>Fri, 09 Jul 2010 16:46:09 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>Howto enable CGI in the builtin OSX webserver</title>
		<link>http://serveradmins.net/howto-enable-cgi-in-the-builtin-osx-webserver/</link>
		<comments>http://serveradmins.net/howto-enable-cgi-in-the-builtin-osx-webserver/#comments</comments>
		<pubDate>Sat, 15 May 2010 00:24:13 +0000</pubDate>
		<dc:creator>chrism</dc:creator>
				<category><![CDATA[Daemons]]></category>
		<category><![CDATA[apache]]></category>
		<category><![CDATA[apple]]></category>
		<category><![CDATA[cgi]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[enable]]></category>
		<category><![CDATA[howto]]></category>
		<category><![CDATA[httpd]]></category>
		<category><![CDATA[osx]]></category>
		<category><![CDATA[Perl]]></category>
		<category><![CDATA[webserver]]></category>

		<guid isPermaLink="false">http://serveradmins.net/?p=74</guid>
		<description><![CDATA[How to setup and enable the builtin Apache webserver in OSX to handle CGI and Perl Applications]]></description>
			<content:encoded><![CDATA[<p>Recently I&#8217;ve caught myself writing more code on my Macbook and for the first time in&#8230; YEARS, not needing an internet connection to actually be productive.  To be quite honest, it&#8217;s a bit weird. <img src='http://serveradmins.net/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>So, the first thing I wanted was the ability to run/exec CGI via a webserver.   At first, I was thinking I&#8217;d go about a source build of Apache, and then I remembered OSX comes with one built in.    Huzzah!</p>
<p>So, first let&#8217;s enable the builtin webserver.</p>
<p>System Preferences -> Sharing, and then click on &#8220;Web Sharing&#8221;.   Go ahead and close out the window now, you&#8217;ve just fired off Apache.  (hooray!).  You should now be able to open your browser of choice and go to http://127.0.0.1/~<username /.   Since I login as 'chrismm', I go to http://127.0.0.1/~chrismm/ .   Here you should see the nifty default page.</p>
<p>Now, the document root is going to be off of your user account in /sites/.   My user is chrismm on my machine, so /Users/chrismm/Sites/ is my public HTML.   Any web content you want to view with the above URL needs to go off of this directory.  Go ahead and add the obligatory "Helloworld.html", I'll wait. <img src='http://serveradmins.net/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>Now that that's done and functioning, I needed to get some hawt hawt Perl/CGI action going on.   This, was incredibly easy.</p>
<p>OSX's main httpd.conf does a per-user http include in /private/etc/apache2/users/<username>.conf, so once again for me, it was /private/etc/apache2/users/chrismm.conf.   This file contains just a super basic Directory configuration for apache to parse and we only need to make one quick change here&#8230;</p>
<p>First and foremost, we need to be the root user, so go ahead and open up Terminal (Finder->Applications->Utilities -> Terminal), and type &#8216;sudo su -&#8217; .   Here, you&#8217;ll be prompted to enter your password.</p>
<p>Keep in mind as soon as you do this, you are the root user on your machine, ***BE VERY CAREFUL AS IF YOU ARE NOT YOU CAN END UP WITH A WORTHLESS WORKSTATION ***.</p>
<p>Now, go ahead and open up the include for your user, at /private/etc/apache2/users/</username><username>.conf, and make the following changes.</p>
<p>Original:<br />
<code><br />
maynard:beta root# cat /private/etc/apache2/users/chrismm.conf<br />
<directory "/Users/chrismm/Sites/"><br />
    Options Indexes MultiViews<br />
    AllowOverride None<br />
    Order allow,deny<br />
    Allow from all<br />
</directory><br />
</code><code></p>
<p>Needs to be changed to....</p>
<p></code><code><br />
maynard:beta root# cat /private/etc/apache2/users/chrismm.conf<br />
<directory "/Users/chrismm/Sites/"><br />
    Options Indexes MultiViews ExecCGI<br />
    AllowOverride None<br />
    Order allow,deny<br />
    Allow from all<br />
</directory><br />
</code></p>
<p>See that?  All I added was &#8220;ExecCGI&#8221; at the end of that Options statement.   We&#8217;re halfway done now!  </p>
<p>One more change&#8230;</p>
<p>Go ahead and open up &#8216;/private/etc/apache2/original/httpd.conf&#8217; in your text editor of choice, and search for &#8221;    #AddHandler cgi-script .cgi&#8221;</p>
<p>Go ahead and remove the &#8216;#&#8217; mark, save and exit.</p>
<p>Now, let&#8217;s restart the webserver&#8230; </p>
<p><code><br />
killall -HUP httpd<br />
</code></p>
<p>Done!</p>
<p>And now, you can use your CGI and be happy. <img src='http://serveradmins.net/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p></username></p>
]]></content:encoded>
			<wfw:commentRss>http://serveradmins.net/howto-enable-cgi-in-the-builtin-osx-webserver/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Systems Administration with Perl and SSH</title>
		<link>http://serveradmins.net/systems-administration-with-perl-and-ssh/</link>
		<comments>http://serveradmins.net/systems-administration-with-perl-and-ssh/#comments</comments>
		<pubDate>Mon, 25 Jan 2010 23:54:10 +0000</pubDate>
		<dc:creator>chrism</dc:creator>
				<category><![CDATA[Scripting]]></category>
		<category><![CDATA[Utility]]></category>
		<category><![CDATA[administration]]></category>
		<category><![CDATA[login]]></category>
		<category><![CDATA[Net::SSH::Perl]]></category>
		<category><![CDATA[Perl]]></category>
		<category><![CDATA[ssh]]></category>
		<category><![CDATA[systems]]></category>

		<guid isPermaLink="false">http://serveradmins.net/?p=45</guid>
		<description><![CDATA[ How to write a basic connection script using Perl's Net::SSH::Perl module.]]></description>
			<content:encoded><![CDATA[<p>Hey there!</p>
<p>Today I wanted to focus on something that&#8217;s helping me do my job in a more efficient fashion.  At a former workplace, I was responsible for ~200 high capacity webhosting machines, and a host of supporting machines.   Back then, I was a huge fan of a management system mostly comprised of SSH Keys and a ton of bash scripts.   It worked, quite well for the time, but if I could do it again, I&#8217;d go with a slightly more refined approach, which is what we&#8217;ll discuss today.</p>
<p>So, let&#8217;s get started.   The first thing you&#8217;ll need is a working perl installation, a few devel libs and a handful of perl modules.  </p>
<p><code> yum install gmp-devel</code><br />
<code>perl -MCPAN -e 'install Crypt::DH , Math::GMP,  Net::SSH::Perl'</code></p>
<p>This is going to install the GMP math development libraries necessary for Math::GMP to compile.   Math::GMP and Crypt::DH are prereqs for Net::SSH::Perl.</p>
<p>So once this is done, we can proceed. <img src='http://serveradmins.net/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p><code><br />
#!/usr/local/bin/perl -w</p>
<p>use strict;<br />
use warnings;<br />
require Net::SSH::Perl;</p>
<p>#declare our login vars...</p>
<p>my $user = "root";<br />
my $password = "SEKUREPASSWORD";<br />
my $server = "localhost";</p>
<p>#Setup our SSH Connection...<br />
my $ssh = Net::SSH::Perl->new($server,port=>22,use_pty=>1);</p>
<p>#Initiate out conneciton to the server...<br />
$ssh->login($user, $password);</p>
<p># Declare our variable for the request...<br />
my $uptime;</p>
<p># Run our SSH Command and retrieve the output...<br />
($uptime) = $ssh->cmd("/usr/bin/uptime");</p>
<p>print "\n$uptime\n";</p>
<p>exit 0; </p>
<p></code></p>
<p>That&#8217;s a very basic/barebones SSH Connection script&#8230;   If you have any questions or problems, please don&#8217;t hesitate to post in the comments. <img src='http://serveradmins.net/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />   </p>
<p>Next up, we&#8217;ll go over a more complex variant of this script using subroutines and a few other nifty tricks. <img src='http://serveradmins.net/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://serveradmins.net/systems-administration-with-perl-and-ssh/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Perl module installation made easy. :)</title>
		<link>http://serveradmins.net/perl-module-installation-made-easy/</link>
		<comments>http://serveradmins.net/perl-module-installation-made-easy/#comments</comments>
		<pubDate>Mon, 25 Jan 2010 00:43:03 +0000</pubDate>
		<dc:creator>chrism</dc:creator>
				<category><![CDATA[Scripting]]></category>
		<category><![CDATA[Utility]]></category>
		<category><![CDATA[centos]]></category>
		<category><![CDATA[cpan]]></category>
		<category><![CDATA[installation]]></category>
		<category><![CDATA[module]]></category>
		<category><![CDATA[Perl]]></category>
		<category><![CDATA[redhat]]></category>

		<guid isPermaLink="false">http://serveradmins.net/?p=46</guid>
		<description><![CDATA[A basic primer on installing perl modules.]]></description>
			<content:encoded><![CDATA[<p>Hey there!</p>
<p>I&#8217;m going to show you a few different ways to install Perl modules in a quick and easy way.  </p>
<p>First up, the one liner. <img src='http://serveradmins.net/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p><code>perl -MCPAN -e 'install HTML::Template'<br />
CPAN: CPAN::SQLite loaded ok (v0.199)<br />
CPAN: LWP::UserAgent loaded ok (v5.834)<br />
CPAN: Time::HiRes loaded ok (v1.9719)<br />
Fetching with LWP:</p>
<p>http://www.stathy.com/CPAN/authors/01mailrc.txt.gz</p>
<p>CPAN: YAML loaded ok (v0.71)<br />
Fetching with LWP:</p>
<p>http://www.stathy.com/CPAN/modules/02packages.details.txt.gz</p>
<p>Fetching with LWP:</p>
<p>http://www.stathy.com/CPAN/modules/03modlist.data.gz</p>
<p>Database was generated on Thu, 21 Jan 2010 20:40:30 GMT<br />
Updating database file ...</p>
<p>Gathering information from index files ...<br />
Obtaining current state of database ...<br />
Populating database tables ...<br />
....  snipped for brevity....<br />
Running make install<br />
Prepending /home/.cpan/build/HTML-Template-2.9-bALXdn/blib/arch /home/.cpan/build/HTML-Template-2.9-bALXdn/blib/lib to PERL5LIB for 'install'<br />
Installing /usr/local/lib/perl5/site_perl/5.8.8/HTML/Template.pm<br />
Appending installation info to /usr/local/lib/perl5/5.8.8/x86_64-linux/perllocal.pod<br />
  SAMTREGAR/HTML-Template-2.9.tar.gz<br />
  /usr/bin/make install UNINST=1 OTHERLDFLAGS=-L/usr/lib64 LDFLAGS=-L/usr/lib64 EXTRALIBDIR=/usr/lib64 -- OK<br />
[root@vps ~]#<br />
</code></p>
<p>And there you go, quick and easy.   </p>
<p>Now a lot of Perl modules are going to require other modules to be built, in which case, you&#8217;ll see something like this&#8230;<br />
<code><br />
Writing Makefile for Net::SSH::Perl<br />
---- Unsatisfied dependencies detected during ----<br />
----     TURNSTEP/Net-SSH-Perl-1.34.tar.gz    ----<br />
    Crypt::DSA [requires]<br />
    Convert::PEM [requires]<br />
    Crypt::RSA [requires]<br />
    Math::Pari [requires]<br />
    Crypt::IDEA [requires]<br />
    Digest::BubbleBabble [requires]<br />
    Crypt::DH [requires]<br />
    Math::GMP [requires]<br />
Shall I follow them and prepend them to the queue<br />
of modules we are processing right now? [yes]<br />
</code></p>
<p>Just go ahead and answer &#8220;yes&#8221; here, and let it continue&#8230;  cpan *should* be smart enough to grab all of the required sources and build what you need, but sometimes, not so much. <img src='http://serveradmins.net/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />    Perl modules are basically subroutines packaged into nice containers, ready to use.  Now some of these require specific programs, libraries or even other perl modules to do what they do best.  When a module has a large chain of dependencies and one of those fails, it can bring the whole show to a screeching halt.  </p>
<p>For an example here, I&#8217;ll use Net::SSH::Perl, which happens to be what I use for a host of different things.</p>
<p>If you use the above listed one-liner to install it, i.e., </p>
<p><code>perl -MCPAN -e 'install HTML::Template'</code></p>
<p>You&#8217;re going to end up seeing this&#8230;</p>
<p><code><br />
Files=12, Tests=106,  1 wallclock secs ( 0.07 usr  0.04 sys +  0.40 cusr  0.14 csys =  0.65 CPU)<br />
Result: PASS<br />
  TURNSTEP/Net-SSH-Perl-1.34.tar.gz<br />
Tests succeeded but 2 dependencies missing (Crypt::DH,Math::GMP)<br />
  TURNSTEP/Net-SSH-Perl-1.34.tar.gz<br />
  [dependencies] -- NA<br />
Running make install<br />
  make test had returned bad status, won't install without force<br />
</code></p>
<p>So, we have a dependency of Net::SSH::Perl that simply isn&#8217;t present.  So let&#8217;s go ahead and get it installed&#8230;</p>
<p>On a RH Based system (CentOS/Trustix/RedHat Enterprise Linux), you can do the following&#8230;</p>
<p><code><br />
yum install gmp-devel<br />
</code></p>
<p>On a Debian based distribution (Debian/Ubuntu, etc)<br />
<code><br />
apt-get install libgmp-ocaml<br />
</code></p>
<p>On FreeBSD, I prefer prots builds personally, so let&#8217;s do the following&#8230;<br />
<code><br />
cd /usr/ports/math/libgmp4<br />
make &#038;&#038; make install<br />
</code></p>
<p>So, now that you&#8217;ve got that taken care of, let&#8217;s proceed. <img src='http://serveradmins.net/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p><code><br />
 perl -MCPAN -e 'install Net::SSH::Perl'<br />
...<br />
...<br />
Tests succeeded but one dependency not OK (Crypt::DH)<br />
  TURNSTEP/Net-SSH-Perl-1.34.tar.gz<br />
  [dependencies] -- NA<br />
Running make install<br />
  make test had returned bad status, won't install without force<br />
</code></p>
<p>So, we need to build Crypt::DH&#8230; Apparently dependency handling isn&#8217;t too bright in this case. <img src='http://serveradmins.net/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />    I&#8217;ll save you the trouble of the blow-by-blow here.  We need to install Crypt::DH which depends on Math::BigInt::GMP.   So, use your handy oneline skills, and get Math::BigInt::GMP installed, then do the same for Crypt::DH.   You should now have a working Net::SSH::Perl installation. <img src='http://serveradmins.net/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>You can specify multiple packages in the following way&#8230;</p>
<p><code><br />
perl -MCPAN -e 'install Net::SSH, Term::ReadLine'<br />
</code></p>
<p>The other option, should cpan fail, is to just grab the module package yourself, which is typically a .tar.gz file, and perform the following.</p>
<p><code><br />
wget http://search.cpan.org/CPAN/authors/id/T/TU/TURNSTEP/Net-SSH-Perl-1.34.tar.gz<br />
tar -xzvf Net-SSH-Perl-1.34.tar.gz<br />
cd ./Net-SSH-Perl-1.34<br />
perl Makefile.PL<br />
make &#038;&#038; make install<br />
</code></p>
<p>That&#8217;s more or less what cpan is doing, except it will try to sort out requirements and dependencies for you (when it can).</p>
<p>So I hope you&#8217;ve learned a bit of something about getting Perl modules installed and running. If you have any questions, feel free to leave a comment. <img src='http://serveradmins.net/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://serveradmins.net/perl-module-installation-made-easy/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
<!-- WP Super Cache is installed but broken. The path to wp-cache-phase1.php in wp-content/advanced-cache.php must be fixed! -->