title: Writing a local file through shell command in Rails
body: <p>I am trying to write a file via shell command in Rails..</p>
  
  <p>Basically I have this:</p>
  
  <pre><code>def self.collect_videos
  
    %x[cd public/videos/ &amp;&amp; exec viddl-rb http://www.youtube.com/watch?v=oHg5SJYRHA0]
       sleep(30)
  end
  </code></pre>
  
  <p>viddl is essentially this: <a href="https://github.com/rb2k/viddl-rb" rel="nofollow">https://github.com/rb2k/viddl-rb</a></p>
  
  <p>It works fine just from rails console, but not when called as a function from Rails app..</p>
  
  <p>How to fix it?</p>