<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
     <title>Latest posts from tom.eustace.net</title>
    <link>http://tom.eustace.net/rss/</link>
    <language>en-us</language>
    <ttl>40</ttl>
    <description>The main posts feed for my Web site.</description>
    
       
          <item>
          <title>Log to file</title>
          <description>&lt;div id=&quot;extra&quot;&gt;
   &lt;div class=&quot;box&quot;&gt;
      &lt;div class=&quot;spot&quot;&gt;
         &lt;a href=&quot;/php&quot;&gt;&lt;img src=&quot;http://713tom.magnus.hostingrails.com/images/tech_logos/php_medium.png&quot; /&gt;&lt;/a&gt;
         &lt;h3&gt;PHP&lt;/h3&gt;
         &lt;p&gt;I've dabbled with PHP in college, using template engines like smarty for college projects.  Recently I've been heavily involved in setting up a
         &lt;a href=&quot;http://www.drupal.org&quot;&gt;Drupal&lt;/a&gt; based site, which has meant getting back into PHP to make various changes to the source to suit our needs.&lt;/p&gt; 
      &lt;/div&gt;
   &lt;/div&gt;
&lt;/div&gt;

&lt;h4 class=&quot;page-title&quot;&gt;Log to file&lt;/h4&gt;

&lt;p&gt;Had to log to file with PHP, used function below.&lt;/p&gt;

&lt;notextile&gt;&lt;div class=&quot;CodeRay&quot;&gt;
  &lt;div class=&quot;code&quot;&gt;&lt;pre&gt;&lt;span class=&quot;no&quot;&gt; 1&lt;/span&gt; &amp;lt;?php
&lt;span class=&quot;no&quot;&gt; 2&lt;/span&gt; function logToFile($msg) { 
&lt;span class=&quot;no&quot;&gt; 3&lt;/span&gt;         // open file
&lt;span class=&quot;no&quot;&gt; 4&lt;/span&gt;         $filename = 'payments.log';
&lt;span class=&quot;no&quot;&gt; 5&lt;/span&gt;         $fd = fopen($filename, &amp;quot;a&amp;quot;);
&lt;span class=&quot;no&quot;&gt; 6&lt;/span&gt;         // append date/time to message
&lt;span class=&quot;no&quot;&gt; 7&lt;/span&gt;         $str = &amp;quot;[&amp;quot; . date(&amp;quot;Y/m/d h:i:s&amp;quot;, mktime()) . &amp;quot;] &amp;quot; . $msg; 
&lt;span class=&quot;no&quot;&gt; 8&lt;/span&gt;         // write string
&lt;span class=&quot;no&quot;&gt; 9&lt;/span&gt;         fwrite($fd, $str . &amp;quot;\n&amp;quot;);
&lt;span class=&quot;no&quot;&gt;&lt;strong&gt;10&lt;/strong&gt;&lt;/span&gt;         // close file
&lt;span class=&quot;no&quot;&gt;11&lt;/span&gt;         fclose($fd);
&lt;span class=&quot;no&quot;&gt;12&lt;/span&gt; }
&lt;span class=&quot;no&quot;&gt;13&lt;/span&gt; ?&amp;gt;&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/notextile&gt;


&lt;div id=&quot;disqus_thread&quot;&gt;&lt;/div&gt;
&lt;script type=&quot;text/javascript&quot;&gt;
  /**
    * var disqus_identifier; [Optional but recommended: Define a unique identifier (e.g. post id or slug) for this thread] 
    */
  (function() {
   var dsq = document.createElement('script'); dsq.type = 'text/javascript'; dsq.async = true;
   dsq.src = 'http://tomeustacesinfodrops.disqus.com/embed.js';
   (document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(dsq);
  })();
&lt;/script&gt;
&lt;noscript&gt;Please enable JavaScript to view the &lt;a href=&quot;http://disqus.com/?ref_noscript=tomeustacesinfodrops&quot;&gt;comments powered by Disqus.&lt;/a&gt;&lt;/noscript&gt;
&lt;a href=&quot;http://disqus.com&quot; class=&quot;dsq-brlink&quot;&gt;blog comments powered by &lt;span class=&quot;logo-disqus&quot;&gt;Disqus&lt;/span&gt;&lt;/a&gt;


</description>
          <pubDate>Sun, 02 Oct 2011 10:11:47 GMT</pubDate>
          <guid>http://tom.eustace.net/php/2011/10/02/log-to-file/</guid>
          <link>http://tom.eustace.net/php/2011/10/02/log-to-file/</link>
        </item>
       
          <item>
          <title>BDD - Rails 3, AutoTest, RSpec and Growl</title>
          <description>&lt;div id=&quot;extra&quot;&gt;
   &lt;div class=&quot;box&quot;&gt;
      &lt;div class=&quot;spot&quot;&gt;
         &lt;a href=&quot;/ruby-on-rails&quot;&gt;&lt;img src=&quot;http://713tom.magnus.hostingrails.com/images/tech_logos/ruby_on_rails_medium.png&quot; /&gt;&lt;/a&gt;
         &lt;h3&gt;Ruby (on Rails)&lt;/h3&gt;
         &lt;p&gt;I've been using Ruby on Rails for a few years, in my spare time, and hope to keep working with it whenever the opportunity arises.  A couple of college friends and 
         I created &lt;a href=&quot;http://www.hospitalpages.ie&quot;&gt;hospitalpages.ie&lt;/a&gt; which is was developed using Ruby on Rails, Git and Capistrano for deployment.
         I also hope to dabble more in pure Ruby scripting, to date I've used it for automating data insertion with MySQL and some file parsing.&lt;/p&gt; 
      &lt;/div&gt;
   &lt;/div&gt;
&lt;/div&gt;

&lt;h4 class=&quot;page-title&quot;&gt;BDD - Rails 3, AutoTest, RSpec and Growl&lt;/h4&gt;

&lt;p&gt;RSpec and AutoTest with Growl notifications set up for Ubuntu 10.10.  Here's what worked for me.  This is a rapid post to help me when I need to do this in the future.  There is a more comprehensive guide for more platforms here &lt;a href=&quot;http://ph7spot.com/musings/getting-started-with-autotest&quot;&gt;http://ph7spot.com/musings/getting-started-with-autotest&lt;/a&gt; &lt;/p&gt;

&lt;p&gt;lines that start with t: are to be run in terminal&lt;/p

&lt;p&gt;t: sudo gem install rspec&lt;/p&gt;

&lt;p&gt;t: sudo gem install rspec-rails&lt;/p&gt;

&lt;p&gt;t: sudo gem install autotest&lt;/p&gt;

&lt;p&gt;t: sudo gem install autotest-rails&lt;/p&gt;

&lt;p&gt;t: sudo gem install autotest-growl&lt;/p&gt;

&lt;p&gt;t: sudo gem install autotest-notification&lt;/p&gt;

&lt;p&gt;t: sudo gem install test_notifier&lt;/p&gt;

&lt;p&gt;t: sudo apt-get install libnotify-bin&lt;/p&gt;

&lt;p&gt;t: find ~/ -iname '.autotest'&lt;/p&gt;

&lt;p&gt;t: sudo gedit &lt;path to .autotest&gt;&lt;/p&gt;

&lt;p&gt;Add following lines .autotest file:&lt;/p&gt;

&lt;p&gt;require &quot;autotest/growl&quot;&lt;/p&gt;
&lt;p&gt;require &quot;test_notifier/autotest&quot;&lt;/p&gt;

&lt;p&gt;t: an-install&lt;/p&gt;

&lt;p&gt;t: rails new some-app-name&gt;&lt;/p&gt;

&lt;p&gt;t: rails scaffold some-name model-details&lt;/p&gt;

&lt;p&gt;t: rake db:migrate (create the database before running this)&lt;/p&gt;

&lt;p&gt;In application.rb of the rails app add the following lines:&lt;/p&gt;

&lt;notextile&gt;&lt;div class=&quot;CodeRay&quot;&gt;
  &lt;div class=&quot;code&quot;&gt;&lt;pre&gt;&lt;span class=&quot;no&quot;&gt;1&lt;/span&gt; config.generators &lt;span class=&quot;r&quot;&gt;do&lt;/span&gt; |g|&amp;lt;&lt;span class=&quot;rx&quot;&gt;&lt;span class=&quot;dl&quot;&gt;/&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;p&amp;gt;
&lt;span class=&quot;no&quot;&gt;2&lt;/span&gt;    g.test_framework :rspec&amp;lt;&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;/&lt;/span&gt;&lt;/span&gt;p&amp;gt;
&lt;span class=&quot;no&quot;&gt;3&lt;/span&gt; &lt;span class=&quot;r&quot;&gt;end&lt;/span&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/notextile&gt;

&lt;p&gt;Add the following to Gemfile of rails application&lt;/p&gt;

&lt;p&gt;gem 'rspec'&lt;/p&gt;
&lt;p&gt;gem 'rspec-rails'&lt;/p&gt;

&lt;p&gt;t: rails generate rspec:install&lt;/p&gt;

&lt;p&gt;t: rake -T spec&lt;/p&gt;

&lt;p&gt;rake -t spec should show you the rspec rake tasks that are now available.&lt;/p&gt;

&lt;p&gt;t: rake spec (this creates the test database entries required for you tests)&lt;/p&gt;

&lt;p&gt;Start autotest under your rails application by typing autotest&lt;/p&gt;

&lt;p&gt;If things have worked you should get a window pop up with a green smiley face, assuming you have some tests that pass, otherwise you'll see a red sad face.&lt;/p&gt;


&lt;div id=&quot;disqus_thread&quot;&gt;&lt;/div&gt;
&lt;script type=&quot;text/javascript&quot;&gt;
  /**
    * var disqus_identifier; [Optional but recommended: Define a unique identifier (e.g. post id or slug) for this thread] 
    */
  (function() {
   var dsq = document.createElement('script'); dsq.type = 'text/javascript'; dsq.async = true;
   dsq.src = 'http://tomeustacesinfodrops.disqus.com/embed.js';
   (document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(dsq);
  })();
&lt;/script&gt;
&lt;noscript&gt;Please enable JavaScript to view the &lt;a href=&quot;http://disqus.com/?ref_noscript=tomeustacesinfodrops&quot;&gt;comments powered by Disqus.&lt;/a&gt;&lt;/noscript&gt;
&lt;a href=&quot;http://disqus.com&quot; class=&quot;dsq-brlink&quot;&gt;blog comments powered by &lt;span class=&quot;logo-disqus&quot;&gt;Disqus&lt;/span&gt;&lt;/a&gt;

</description>
          <pubDate>Sat, 30 Apr 2011 12:09:05 GMT</pubDate>
          <guid>http://tom.eustace.net/ruby-on-rails/2011/04/30/bdd---rails-3-autotest-rspec-and-growl/</guid>
          <link>http://tom.eustace.net/ruby-on-rails/2011/04/30/bdd---rails-3-autotest-rspec-and-growl/</link>
        </item>
       
          <item>
          <title>Get value from checkbox in rails (2.0.4)</title>
          <description>&lt;div id=&quot;extra&quot;&gt;
   &lt;div class=&quot;box&quot;&gt;
      &lt;div class=&quot;spot&quot;&gt;
         &lt;a href=&quot;/ruby-on-rails&quot;&gt;&lt;img src=&quot;http://713tom.magnus.hostingrails.com/images/tech_logos/ruby_on_rails_medium.png&quot; /&gt;&lt;/a&gt;
         &lt;h3&gt;Ruby (on Rails)&lt;/h3&gt;
         &lt;p&gt;I've been using Ruby on Rails for a few years, in my spare time, and hope to keep working with it whenever the opportunity arises.  A couple of college friends and 
         I created &lt;a href=&quot;http://www.hospitalpages.ie&quot;&gt;hospitalpages.ie&lt;/a&gt; which is was developed using Ruby on Rails, Git and Capistrano for deployment.
         I also hope to dabble more in pure Ruby scripting, to date I've used it for automating data insertion with MySQL and some file parsing.&lt;/p&gt; 
      &lt;/div&gt;
   &lt;/div&gt;
&lt;/div&gt;

&lt;h4 class=&quot;page-title&quot;&gt;Get value from checkbox in rails (2.0.4)&lt;/h4&gt;

&lt;p&gt;With below checkbox, access the value in controller with something like :params[checkbox_name], e.g. if (:params[checkbox_name] == 'selected') # do something.. &lt;/p&gt;

&lt;notextile&gt;&lt;div class=&quot;CodeRay&quot;&gt;
  &lt;div class=&quot;code&quot;&gt;&lt;pre&gt;&lt;span class=&quot;no&quot;&gt;1&lt;/span&gt; &lt;span class=&quot;c&quot;&gt;&amp;lt;%= check_box_tag 'checkbox_name', 'selected' %&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/notextile&gt;

&lt;p&gt;&lt;/p&gt;
&lt;p&gt;becomes:&lt;/p&gt;

&lt;notextile&gt;&lt;div class=&quot;CodeRay&quot;&gt;
  &lt;div class=&quot;code&quot;&gt;&lt;pre&gt;&lt;span class=&quot;no&quot;&gt;1&lt;/span&gt; &lt;span class=&quot;ta&quot;&gt;&amp;lt;input&lt;/span&gt; &lt;span class=&quot;an&quot;&gt;type&lt;/span&gt;=&lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;checkbox&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;an&quot;&gt;value&lt;/span&gt;=&lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;selected&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;an&quot;&gt;name&lt;/span&gt;=&lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;checkbox_name&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;an&quot;&gt;id&lt;/span&gt;=&lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;checkbox_name&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;ta&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/notextile&gt;

&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Note if the checkbox is not selected you won't be able to access the value, it is only accessible if the checkbox is selected.&lt;/p&gt;

&lt;div id=&quot;disqus_thread&quot;&gt;&lt;/div&gt;
&lt;script type=&quot;text/javascript&quot;&gt;
  /**
    * var disqus_identifier; [Optional but recommended: Define a unique identifier (e.g. post id or slug) for this thread] 
    */
  (function() {
   var dsq = document.createElement('script'); dsq.type = 'text/javascript'; dsq.async = true;
   dsq.src = 'http://tomeustacesinfodrops.disqus.com/embed.js';
   (document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(dsq);
  })();
&lt;/script&gt;
&lt;noscript&gt;Please enable JavaScript to view the &lt;a href=&quot;http://disqus.com/?ref_noscript=tomeustacesinfodrops&quot;&gt;comments powered by Disqus.&lt;/a&gt;&lt;/noscript&gt;
&lt;a href=&quot;http://disqus.com&quot; class=&quot;dsq-brlink&quot;&gt;blog comments powered by &lt;span class=&quot;logo-disqus&quot;&gt;Disqus&lt;/span&gt;&lt;/a&gt;

</description>
          <pubDate>Fri, 25 Feb 2011 15:23:11 GMT</pubDate>
          <guid>http://tom.eustace.net/ruby-on-rails/2011/02/25/get-value-from-checkbox-in-rails-2-0-4/</guid>
          <link>http://tom.eustace.net/ruby-on-rails/2011/02/25/get-value-from-checkbox-in-rails-2-0-4/</link>
        </item>
       
          <item>
          <title>RubyMine setup and launch application as root</title>
          <description>&lt;div id=&quot;extra&quot;&gt;
   &lt;div class=&quot;box&quot;&gt;
      &lt;div class=&quot;spot&quot;&gt;
         &lt;a href=&quot;/ubuntu&quot;&gt;&lt;img src=&quot;http://713tom.magnus.hostingrails.com/images/tech_logos/ubuntu_medium.png&quot; /&gt;&lt;/a&gt;
         &lt;h3&gt;Ubuntu&lt;/h3&gt;
         &lt;p&gt;I've been running Ubuntu since early 2007.  Had a few teething problems with sound cards at the start but worked around them by using OSS.  Happily 
         the necessary drivers were updated in the latest releases.  Below are tricks picked up over the years of using Ubuntu.&lt;/p&gt; 
      &lt;/div&gt;
   &lt;/div&gt;
&lt;/div&gt;

&lt;h4 class=&quot;page-title&quot;&gt;RubyMine setup and launch application as root&lt;/h4&gt;

&lt;p&gt;I have openjdk installed as well as sun jdk, so when I ran rubymine I was getting a warning message about using openjdk.  So to fix this the below line was added to the rubymine.sh file:&lt;/p&gt;
&lt;p&gt;&lt;i&gt;export JDK_HOME=/usr/lib/jvm/java-6-sun-1.6.0.22&lt;/i&gt;&lt;/p&gt;

&lt;p&gt;Next I wanted to set up a launcher for RubyMine, here's what I did.&lt;/p&gt;

&lt;p&gt;Right click and select &quot;Add to Panel&quot;, select &quot;Custom Application Launcher&quot;, select &quot;Add&quot;.  For Type select &quot;Application in Terminal&quot;, choose a name, the command should start with gksudo followed by the location of rubymine.sh.  So full command is something like: &lt;/p&gt;

&lt;p&gt;&lt;i&gt;gksudo /path/to/rubymine.sh&lt;/i&gt;&lt;/p&gt;


&lt;div id=&quot;disqus_thread&quot;&gt;&lt;/div&gt;
&lt;script type=&quot;text/javascript&quot;&gt;
  /**
    * var disqus_identifier; [Optional but recommended: Define a unique identifier (e.g. post id or slug) for this thread] 
    */
  (function() {
   var dsq = document.createElement('script'); dsq.type = 'text/javascript'; dsq.async = true;
   dsq.src = 'http://tomeustacesinfodrops.disqus.com/embed.js';
   (document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(dsq);
  })();
&lt;/script&gt;
&lt;noscript&gt;Please enable JavaScript to view the &lt;a href=&quot;http://disqus.com/?ref_noscript=tomeustacesinfodrops&quot;&gt;comments powered by Disqus.&lt;/a&gt;&lt;/noscript&gt;
&lt;a href=&quot;http://disqus.com&quot; class=&quot;dsq-brlink&quot;&gt;blog comments powered by &lt;span class=&quot;logo-disqus&quot;&gt;Disqus&lt;/span&gt;&lt;/a&gt;
</description>
          <pubDate>Wed, 23 Feb 2011 18:20:29 GMT</pubDate>
          <guid>http://tom.eustace.net/ubuntu/2011/02/23/rubymine-setup-and-launch-application-as-root/</guid>
          <link>http://tom.eustace.net/ubuntu/2011/02/23/rubymine-setup-and-launch-application-as-root/</link>
        </item>
       
          <item>
          <title>Public Keys accessing github gives Agent admitted failure to sign using the key.</title>
          <description>&lt;div id=&quot;extra&quot;&gt;
   &lt;div class=&quot;box&quot;&gt;
      &lt;div class=&quot;spot&quot;&gt;
         &lt;a href=&quot;/ubuntu&quot;&gt;&lt;img src=&quot;http://713tom.magnus.hostingrails.com/images/tech_logos/ubuntu_medium.png&quot; /&gt;&lt;/a&gt;
         &lt;h3&gt;Ubuntu&lt;/h3&gt;
         &lt;p&gt;I've been running Ubuntu since early 2007.  Had a few teething problems with sound cards at the start but worked around them by using OSS.  Happily 
         the necessary drivers were updated in the latest releases.  Below are tricks picked up over the years of using Ubuntu.&lt;/p&gt; 
      &lt;/div&gt;
   &lt;/div&gt;
&lt;/div&gt;

&lt;h4 class=&quot;page-title&quot;&gt;Public Keys accessing github gives Agent admitted failure to sign using the key.&lt;/h4&gt;

&lt;p&gt;Got this error recently when trying to connect to github, having not connected for awhile:&lt;/p&gt;

&lt;p&gt;
&lt;i&gt;
Agent admitted failure to sign using the key.
Permission denied (publickey).
&lt;/i&gt;
&lt;/p&gt;

&lt;p&gt;To workaround run: sudo export SSH_AUTH_SOCK=0&lt;/p&gt;


&lt;div id=&quot;disqus_thread&quot;&gt;&lt;/div&gt;
&lt;script type=&quot;text/javascript&quot;&gt;
  /**
    * var disqus_identifier; [Optional but recommended: Define a unique identifier (e.g. post id or slug) for this thread] 
    */
  (function() {
   var dsq = document.createElement('script'); dsq.type = 'text/javascript'; dsq.async = true;
   dsq.src = 'http://tomeustacesinfodrops.disqus.com/embed.js';
   (document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(dsq);
  })();
&lt;/script&gt;
&lt;noscript&gt;Please enable JavaScript to view the &lt;a href=&quot;http://disqus.com/?ref_noscript=tomeustacesinfodrops&quot;&gt;comments powered by Disqus.&lt;/a&gt;&lt;/noscript&gt;
&lt;a href=&quot;http://disqus.com&quot; class=&quot;dsq-brlink&quot;&gt;blog comments powered by &lt;span class=&quot;logo-disqus&quot;&gt;Disqus&lt;/span&gt;&lt;/a&gt;
</description>
          <pubDate>Fri, 21 Jan 2011 19:48:34 GMT</pubDate>
          <guid>http://tom.eustace.net/ubuntu/2011/01/21/public-keys-accessing-github-gives-agent-admitted-failure-to-sign-using-the-key-/</guid>
          <link>http://tom.eustace.net/ubuntu/2011/01/21/public-keys-accessing-github-gives-agent-admitted-failure-to-sign-using-the-key-/</link>
        </item>
       
          <item>
          <title>FTP with Ruby</title>
          <description>&lt;div id=&quot;extra&quot;&gt;
   &lt;div class=&quot;box&quot;&gt;
      &lt;div class=&quot;spot&quot;&gt;
         &lt;a href=&quot;/ruby-on-rails&quot;&gt;&lt;img src=&quot;http://713tom.magnus.hostingrails.com/images/tech_logos/ruby_on_rails_medium.png&quot; /&gt;&lt;/a&gt;
         &lt;h3&gt;Ruby (on Rails)&lt;/h3&gt;
         &lt;p&gt;I've been using Ruby on Rails for a few years, in my spare time, and hope to keep working with it whenever the opportunity arises.  A couple of college friends and 
         I created &lt;a href=&quot;http://www.hospitalpages.ie&quot;&gt;hospitalpages.ie&lt;/a&gt; which is was developed using Ruby on Rails, Git and Capistrano for deployment.
         I also hope to dabble more in pure Ruby scripting, to date I've used it for automating data insertion with MySQL and some file parsing.&lt;/p&gt; 
      &lt;/div&gt;
   &lt;/div&gt;
&lt;/div&gt;

&lt;h4 class=&quot;page-title&quot;&gt;FTP with Ruby&lt;/h4&gt;

&lt;notextile&gt;&lt;div class=&quot;CodeRay&quot;&gt;
  &lt;div class=&quot;code&quot;&gt;&lt;pre&gt;&lt;span class=&quot;no&quot;&gt;1&lt;/span&gt; require &lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;'&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;net/ftp&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;'&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;no&quot;&gt;2&lt;/span&gt; ftp=&lt;span class=&quot;co&quot;&gt;Net&lt;/span&gt;::&lt;span class=&quot;co&quot;&gt;FTP&lt;/span&gt;.new
&lt;span class=&quot;no&quot;&gt;3&lt;/span&gt; ftp.connect(&lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;www.domain.com&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;,&lt;span class=&quot;i&quot;&gt;21&lt;/span&gt;)
&lt;span class=&quot;no&quot;&gt;4&lt;/span&gt; ftp.login(&lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;username&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;,&lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;password&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;)
&lt;span class=&quot;no&quot;&gt;5&lt;/span&gt; ftp.chdir(&lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;/target/path/on/server&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;)
&lt;span class=&quot;no&quot;&gt;6&lt;/span&gt; ftp.puttextfile(&lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;/local/path/to/file/uploadme.txt&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;,&lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;/target/path/on/server/uploadme.txt&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;)
&lt;span class=&quot;no&quot;&gt;7&lt;/span&gt; ftp.close&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/notextile&gt;


&lt;div id=&quot;disqus_thread&quot;&gt;&lt;/div&gt;
&lt;script type=&quot;text/javascript&quot;&gt;
  /**
    * var disqus_identifier; [Optional but recommended: Define a unique identifier (e.g. post id or slug) for this thread] 
    */
  (function() {
   var dsq = document.createElement('script'); dsq.type = 'text/javascript'; dsq.async = true;
   dsq.src = 'http://tomeustacesinfodrops.disqus.com/embed.js';
   (document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(dsq);
  })();
&lt;/script&gt;
&lt;noscript&gt;Please enable JavaScript to view the &lt;a href=&quot;http://disqus.com/?ref_noscript=tomeustacesinfodrops&quot;&gt;comments powered by Disqus.&lt;/a&gt;&lt;/noscript&gt;
&lt;a href=&quot;http://disqus.com&quot; class=&quot;dsq-brlink&quot;&gt;blog comments powered by &lt;span class=&quot;logo-disqus&quot;&gt;Disqus&lt;/span&gt;&lt;/a&gt;
</description>
          <pubDate>Wed, 22 Dec 2010 14:22:04 GMT</pubDate>
          <guid>http://tom.eustace.net/ruby-on-rails/2010/12/22/ftp-with-ruby/</guid>
          <link>http://tom.eustace.net/ruby-on-rails/2010/12/22/ftp-with-ruby/</link>
        </item>
       
    
   </channel>
</rss>

