<?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>herbertm.ca &#187; Development</title>
	<atom:link href="http://blog.herbertm.ca/articles/category/devel/feed" rel="self" type="application/rss+xml" />
	<link>http://blog.herbertm.ca</link>
	<description></description>
	<lastBuildDate>Mon, 30 May 2011 18:49:41 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>Mercurial Central Repository with fastcgi and nginx</title>
		<link>http://blog.herbertm.ca/archives/334</link>
		<comments>http://blog.herbertm.ca/archives/334#comments</comments>
		<pubDate>Thu, 04 Mar 2010 20:23:41 +0000</pubDate>
		<dc:creator>Herb</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[Internet]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[fastcgi]]></category>
		<category><![CDATA[mercurial]]></category>
		<category><![CDATA[nginx]]></category>

		<guid isPermaLink="false">http://blog.herbertm.ca/?p=334</guid>
		<description><![CDATA[Documentation in this arena being slim, I felt it would be helpful to write a short article on my configuration. FastCGI examples are generally documented in about two or three blog posts on the subject, all of which have become dated. For the basic ground work take a look at streamhacker. Firstly, the fastcgi process [...]]]></description>
			<content:encoded><![CDATA[<p></p><p>Documentation in this arena being slim, I felt it would be helpful to write a short article on my configuration. FastCGI examples are generally documented in about <a href="http://www.dikant.de/2009/07/29/running-mercurial-with-fastcgi-in-nginx/">two</a> or <a href="http://geeksharp.com/2010/01/20/mercurial-web-with-fastcgi-nginx/">three</a> blog posts on the subject, all of which have become dated. For the basic ground work take a look at <a href="http://streamhacker.com/2009/07/28/how-to-deploy-hgwebdir-fcgi-behind-nginx-with-fab/comment-page-1">streamhacker</a>.</p>

<p>Firstly, the fastcgi process is unaware whether you are using <span class="caps">HTTP </span>or <span class="caps">HTTPS, </span>another fastcgi_param must be passed to solve the following error:</p>


<pre>
searching for changes
ssl required
</pre>




<pre>
fastcgi_param   HTTPS           on;
</pre>



<p>If you are having the following error, and you have ensured that <span class="caps">HTTPS </span>is functioning and allow_push = username is specified in the repo&#8217;s <em>.hg/hgrc</em>:</p>


<pre>
searching for changes
27 changesets found
abort: authorization failed
</pre>



<p>Then the fastcgi process isn&#8217;t receiving the username from nginx. Ensure that the following lines are added to your nginx config:</p>


<pre>
fastcgi_param   AUTH_USER       $remote_user;
fastcgi_param   REMOTE_USER     $remote_user;
</pre>



<p>Nginx is also liable to spit out a:</p>


<pre>413 Request Entity Too Large</pre>


<p>on your first major commit. This is because the max_body_size is set low by default and is unacceptable for a mercurial application. Ensure to add and modify this line to your needs:</p>


<pre>
client_max_body_size    100M;
</pre>


<p><strong>my entire nginx vhost.conf</strong></p>


<pre>
server {
    listen      443;
    server_name hg.DOMAIN.COM;

    ssl                  on;
    ssl_certificate      server.crt;
    ssl_certificate_key  server.key;
    ssl_session_timeout  5m;
    ssl_protocols  SSLv2 SSLv3 TLSv1;
    ssl_ciphers  ALL:!ADH:!EXPORT56:RC4+RSA:+HIGH:+MEDIUM:+LOW:+SSLv2:+EXP;
    ssl_prefer_server_ciphers   on;

        # Increase transfer size to accommodate large pushes
        client_max_body_size    100M;

        location / {
                auth_basic &quot;Restricted Access&quot;;
                auth_basic_user_file /repo/sites/hg.DOMAIN.COM/mercurial_passwd;
                fastcgi_pass    127.0.0.1:9001;
                fastcgi_param   PATH_INFO       $fastcgi_script_name;
                fastcgi_param   AUTH_USER       $remote_user;
                fastcgi_param   REMOTE_USER     $remote_user;
                fastcgi_param   QUERY_STRING    $query_string;
                fastcgi_param   REQUEST_METHOD  $request_method;
                fastcgi_param   CONTENT_TYPE    $content_type;
                fastcgi_param   CONTENT_LENGTH  $content_length;
                fastcgi_param   SERVER_PROTOCOL $server_protocol;
                fastcgi_param   SERVER_PORT     $server_port;
                fastcgi_param   SERVER_NAME     $server_name;
                fastcgi_param   HTTPS           on;
        }
        location ~ /\.ht {
            deny  all;
        }
}
</pre>]]></content:encoded>
			<wfw:commentRss>http://blog.herbertm.ca/archives/334/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>mercurial clone from ssh with spaces</title>
		<link>http://blog.herbertm.ca/archives/331</link>
		<comments>http://blog.herbertm.ca/archives/331#comments</comments>
		<pubDate>Tue, 23 Feb 2010 20:45:54 +0000</pubDate>
		<dc:creator>Herb</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[mercurial]]></category>

		<guid isPermaLink="false">http://blog.herbertm.ca/?p=331</guid>
		<description><![CDATA[hg clone ssh://user@host/path/to/repo Is simple enough&#8230; But what about when you have a repo called &#8220;big repo&#8221;. Took me a while to figure out (with ssh verbosity) that a combination of the regular special character &#8216;\&#8217; and quotes is required for hg to call the right ssh command. hg clone &#34;ssh://user@host/path/to/big\ repo&#34;]]></description>
			<content:encoded><![CDATA[<p></p><pre>
hg clone ssh://user@host/path/to/repo
</pre>


<p>Is simple enough&#8230;</p>

<p>But what about when you have a repo called &#8220;big repo&#8221;. Took me a while to figure out (with ssh verbosity) that a combination of the regular special character &#8216;\&#8217; and quotes is required for hg to call the right ssh command.</p>


<pre>
hg clone &quot;ssh://user@host/path/to/big\ repo&quot;
</pre>]]></content:encoded>
			<wfw:commentRss>http://blog.herbertm.ca/archives/331/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>A Simple Test</title>
		<link>http://blog.herbertm.ca/archives/327</link>
		<comments>http://blog.herbertm.ca/archives/327#comments</comments>
		<pubDate>Sat, 13 Feb 2010 01:16:40 +0000</pubDate>
		<dc:creator>Herb</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[Linux]]></category>

		<guid isPermaLink="false">http://blog.herbertm.ca/?p=327</guid>
		<description><![CDATA[A simple test this evening between two FreeBSD 8.0-RELEASE machines. OpenVPN 2.1.1 compile from ports (source). gen2 i386, Pentium 4 2.0GHz 2.0GB circa 2003 [root@gen2 /usr/ports/security/openvpn]# make install real 4m11.491s user 1m46.402s sys 0m26.863s blackbox i386, Athlon Thunderbird 1.0GHz 512MB circa 2001 [root@blackbox /usr/ports/security/openvpn]# make install real 6m9.970s user 3m15.515s sys 0m43.739s]]></description>
			<content:encoded><![CDATA[<p></p><p>A simple test this evening between two FreeBSD 8.0-RELEASE machines. OpenVPN 2.1.1 compile from ports (source).</p>

<p><strong>gen2</strong> <em>i386, Pentium 4 2.0GHz 2.0GB circa 2003</em></p>


<pre>
[root@gen2 /usr/ports/security/openvpn]# make install
real	4m11.491s
user	1m46.402s
sys	0m26.863s
</pre>



<p><strong>blackbox</strong> <em>i386, Athlon Thunderbird 1.0GHz 512MB circa 2001</em></p>


<pre>
[root@blackbox /usr/ports/security/openvpn]# make install
real	6m9.970s
user	3m15.515s
sys	0m43.739s
</pre>]]></content:encoded>
			<wfw:commentRss>http://blog.herbertm.ca/archives/327/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Asterisk 1.6 CDR &#8211; CSV to PgSQL</title>
		<link>http://blog.herbertm.ca/archives/260</link>
		<comments>http://blog.herbertm.ca/archives/260#comments</comments>
		<pubDate>Wed, 09 Dec 2009 21:06:54 +0000</pubDate>
		<dc:creator>Herb</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[asterisk]]></category>

		<guid isPermaLink="false">http://blog.herbertm.ca/?p=260</guid>
		<description><![CDATA[Damn, perl is ugly by today&#8217;s standards, but I found this old script kicking about so I decided to dust it off and make it useable. This happens alot with asterisk code posted on the various wikis. Using the newer Text::CSV_XS library and the latest asterisk column structure I&#8217;ve made it work as below to [...]]]></description>
			<content:encoded><![CDATA[<p></p><p>Damn, perl is ugly by today&#8217;s standards, but I found this old script <a href="http://www.voip-info.org/wiki/view/Asterisk+CDR+Master.csv+postgresql+Perl+import">kicking about</a> so I decided to dust it off and make it useable. This happens alot with asterisk code posted on the various wikis.</p>

<p>Using the newer <a href="http://search.cpan.org/~hmbrand/Text-CSV_XS-0.70/CSV_XS.pm">Text::CSV_XS</a> library and the latest asterisk <a href="http://www.packtpub.com/article/quality-assurance-in-asterisk-1-6">column structure</a> I&#8217;ve made it work as below to import about 4500 rows from cdr_csv on a production system. Enjoy! Glad to be back.</p>

<p><strong>Pre-requisites:</strong></p>


<pre>DBD::Pg
Text::CSV_XS</pre>




<div class="wp_syntax"><div class="code"><pre class="perl" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">#!/usr/bin/perl -w</span>
<span style="color: #666666; font-style: italic;"># Asterisk 1.6 CDR_CSV import to PGSQL</span>
<span style="color: #666666; font-style: italic;"># Herbert Molenda &lt;me at herbertm.ca&gt; - 2009-12-09</span>
<span style="color: #666666; font-style: italic;"># updated from original by StÃ©phane HENRY stephane.henry (=at=) heberge.net - 2007-03-20</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">use</span> strict<span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">use</span> DBI<span style="color: #339933;">;</span> 
<span style="color: #000000; font-weight: bold;">use</span> Text<span style="color: #339933;">::</span><span style="color: #006600;">CSV_XS</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># this script import asterisk cdr log Master.csv into a postgresql table</span>
&nbsp;
<span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$cdr_log_file</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">$ARGV</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span> 
<span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$pg_host</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">$ARGV</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span> 
<span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$pg_db</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">$ARGV</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">2</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span> 
<span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$pg_table</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">$ARGV</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">3</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span> 
<span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$pg_user</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">$ARGV</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">4</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span> 
<span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$pg_pwd</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">$ARGV</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">5</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span> 
<span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$csv</span> <span style="color: #339933;">=</span> Text<span style="color: #339933;">::</span><span style="color: #006600;">CSV_XS</span><span style="color: #339933;">-&gt;</span><span style="color: #006600;">new</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span> quote_char <span style="color: #339933;">=&gt;</span> <span style="color: #ff0000;">'&quot;'</span><span style="color: #339933;">,</span> always_quote <span style="color: #339933;">=&gt;</span> <span style="color: #cc66cc;">1</span> <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #0000ff;">&amp;usage</span> <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><span style="color: #0000ff;">$ARGV</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">5</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> 
&nbsp;
&nbsp;
<span style="color: #666666; font-style: italic;"># Connect to database </span>
<span style="color: #000066;">print</span> <span style="color: #ff0000;">&quot;Connecting to database...<span style="color: #000099; font-weight: bold;">\n</span><span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span> 
&nbsp;
<span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$dsn</span><span style="color: #339933;">=</span><span style="color: #ff0000;">&quot;DBI:Pg:dbname=$pg_db;host=$pg_host;port=5432&quot;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$dbh</span><span style="color: #339933;">=</span>DBI<span style="color: #339933;">-&gt;</span><span style="color: #006600;">connect</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$dsn</span><span style="color: #339933;">,</span><span style="color: #0000ff;">$pg_user</span><span style="color: #339933;">,</span><span style="color: #0000ff;">$pg_pwd</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$dbh</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	<span style="color: #000066;">print</span> <span style="color: #ff0000;">&quot;Successfully connected to $dsn<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span>
	<span style="color: #000066;">open</span> cdr_log<span style="color: #339933;">,</span> <span style="color: #ff0000;">&quot;&lt; $cdr_log_file&quot;</span> <span style="color: #b1b100;">or</span> <span style="color: #000066;">die</span> <span style="color: #ff0000;">&quot;Cannot open cdr_log_file<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span>
	<span style="color: #b1b100;">while</span> <span style="color: #009900;">&#40;</span><span style="color: #009999;">&lt;cdr_log&gt;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
            <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$csv</span><span style="color: #339933;">-&gt;</span><span style="color: #006600;">parse</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$_</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> 
		<span style="color: #b1b100;">my</span> <span style="color: #009900;">&#40;</span><span style="color: #0000ff;">@fields</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">$csv</span><span style="color: #339933;">-&gt;</span><span style="color: #006600;">fields</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> 
		<span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$insert_str</span> <span style="color: #339933;">=</span> <span style="color: #ff0000;">&quot;insert into $pg_table (src, dst, dcontext, clid, channel, dstchannel, lastapp, lastdata, calldate, duration, billsec, disposition, uniqueid, userfield) values (<span style="color: #000099; font-weight: bold;">\'</span>&quot;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">$fields</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">.</span><span style="color: #ff0000;">&quot;<span style="color: #000099; font-weight: bold;">\'</span>, <span style="color: #000099; font-weight: bold;">\'</span>&quot;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">$fields</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">2</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">.</span><span style="color: #ff0000;">&quot;<span style="color: #000099; font-weight: bold;">\'</span>, <span style="color: #000099; font-weight: bold;">\'</span>&quot;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">$fields</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">3</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">.</span><span style="color: #ff0000;">&quot;<span style="color: #000099; font-weight: bold;">\'</span>, <span style="color: #000099; font-weight: bold;">\'</span>&quot;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">$fields</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">4</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">.</span><span style="color: #ff0000;">&quot;<span style="color: #000099; font-weight: bold;">\'</span>, <span style="color: #000099; font-weight: bold;">\'</span>&quot;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">$fields</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">5</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">.</span><span style="color: #ff0000;">&quot;<span style="color: #000099; font-weight: bold;">\'</span>, <span style="color: #000099; font-weight: bold;">\'</span>&quot;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">$fields</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">6</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">.</span><span style="color: #ff0000;">&quot;<span style="color: #000099; font-weight: bold;">\'</span>, <span style="color: #000099; font-weight: bold;">\'</span>&quot;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">$fields</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">7</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">.</span><span style="color: #ff0000;">&quot;<span style="color: #000099; font-weight: bold;">\'</span>, <span style="color: #000099; font-weight: bold;">\'</span>&quot;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">$fields</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">8</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">.</span><span style="color: #ff0000;">&quot;<span style="color: #000099; font-weight: bold;">\'</span>, <span style="color: #000099; font-weight: bold;">\'</span>&quot;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">$fields</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">9</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">.</span><span style="color: #ff0000;">&quot;<span style="color: #000099; font-weight: bold;">\'</span>, <span style="color: #000099; font-weight: bold;">\'</span>&quot;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">$fields</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">12</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">.</span><span style="color: #ff0000;">&quot;<span style="color: #000099; font-weight: bold;">\'</span>, <span style="color: #000099; font-weight: bold;">\'</span>&quot;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">$fields</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">13</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">.</span><span style="color: #ff0000;">&quot;<span style="color: #000099; font-weight: bold;">\'</span>, <span style="color: #000099; font-weight: bold;">\'</span>&quot;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">$fields</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">14</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">.</span><span style="color: #ff0000;">&quot;<span style="color: #000099; font-weight: bold;">\'</span>, <span style="color: #000099; font-weight: bold;">\'</span>&quot;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">$fields</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">16</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">.</span><span style="color: #ff0000;">&quot;<span style="color: #000099; font-weight: bold;">\'</span>, <span style="color: #000099; font-weight: bold;">\'</span>&quot;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">$fields</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">17</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">.</span><span style="color: #ff0000;">&quot;<span style="color: #000099; font-weight: bold;">\'</span>);&quot;</span><span style="color: #339933;">;</span> 
		<span style="color: #000066;">print</span> <span style="color: #0000ff;">$insert_str</span><span style="color: #339933;">.</span><span style="color: #ff0000;">&quot;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span>
		<span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$sth</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">$dbh</span><span style="color: #339933;">-&gt;</span><span style="color: #006600;">prepare</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$insert_str</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> 
		<span style="color: #0000ff;">$sth</span><span style="color: #339933;">-&gt;</span><span style="color: #006600;">execute</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> 
		<span style="color: #0000ff;">$sth</span><span style="color: #339933;">-&gt;</span><span style="color: #006600;">finish</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> 
	    <span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">else</span> <span style="color: #009900;">&#123;</span>
	        <span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$err</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">$csv</span><span style="color: #339933;">-&gt;</span><span style="color: #006600;">error_input</span><span style="color: #339933;">;</span>
        	<span style="color: #000066;">print</span> <span style="color: #ff0000;">&quot;Failed to parse line: $err&quot;</span><span style="color: #339933;">;</span>
	    <span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #009900;">&#125;</span> 
	<span style="color: #0000ff;">$dbh</span><span style="color: #339933;">-&gt;</span><span style="color: #006600;">disconnect</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> 
	<span style="color: #000066;">close</span> <span style="color: #009900;">&#40;</span>cdr_log<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> 
<span style="color: #009900;">&#125;</span>
<span style="color: #b1b100;">else</span><span style="color: #009900;">&#123;</span>
	<span style="color: #000066;">die</span><span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;Problem connecting to : $dsn<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #000066;">print</span> <span style="color: #ff0000;">&quot;<span style="color: #000099; font-weight: bold;">\n</span><span style="color: #000099; font-weight: bold;">\n</span>End.<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span> 
<span style="color: #000066;">exit</span><span style="color: #339933;">;</span> 
&nbsp;
&nbsp;
<span style="color: #000000; font-weight: bold;">sub</span> usage<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> 
       print_header<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> 
       <span style="color: #000066;">print</span> <span style="color: #ff0000;">&quot;<span style="color: #000099; font-weight: bold;">\n</span>Usage: perl cdr_csv2pgsql.pl &lt;cdr_log_file&gt; &lt;pg_hostname&gt; &lt;database&gt; &lt;table&gt; &lt;username&gt; &lt;password&gt;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span> 
       <span style="color: #000066;">die</span><span style="color: #339933;">;</span> 
<span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span> 
&nbsp;
<span style="color: #000000; font-weight: bold;">sub</span> print_header<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> 
       <span style="color: #000066;">print</span> <span style="color: #ff0000;">&quot;<span style="color: #000099; font-weight: bold;">\n</span>cdr_csv2pgsql.pl - Asterisk 1.6 CDR_CSV import to PGSQL<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span> 
<span style="color: #009900;">&#125;</span> <span style="color: #339933;">&lt;/</span>password<span style="color: #339933;">&gt;&lt;/</span>username<span style="color: #339933;">&gt;&lt;/</span>table<span style="color: #339933;">&gt;&lt;/</span>database<span style="color: #339933;">&gt;&lt;/</span>pg_hostname<span style="color: #339933;">&gt;&lt;/</span>cdr_log_file<span style="color: #339933;">&gt;&lt;/</span>me<span style="color: #339933;">&gt;</span></pre></div></div>
]]></content:encoded>
			<wfw:commentRss>http://blog.herbertm.ca/archives/260/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

