title: unix at command pass variable to shell script?
body: <p>I'm trying to setup a simple timer that gets started from a Rails Application.  This timer should wait out its duration and then start a shell script that will start up ./script/runner and complete the initial request.  I need script/runner because I need access to ActiveRecord.</p>
  
  <p>Here's my test lines in Rails</p>
  
  <pre><code>output = `at #{(Time.now + 60).strftime("%H:%M")} &lt; #{Rails.root}/lib/parking_timer.sh STRING_VARIABLE`
  return render :text =&gt; output
  </code></pre>
  
  <p>Then my parking_timer.sh looks like this</p>
  
  <pre><code>#!/bin/sh               
  ~/PATH_TO_APP/script/runner -e development ~/PATH_TO_APP/lib/ParkingTimer.rb $1
  echo "All Done"    
  </code></pre>
  
  <p>Finally, ParkingTimer.rb reads the passed variable with</p>
  
  <pre><code>ARGV.each do|a|
     puts "Argument: #{a}"
  end
  </code></pre>
  
  <p>The problem is that the Unix command "at" doesn't seem to like variables and only wants to deal with filenames.  I either get one of two errors depending on how I position "s</p>
  
  <p>If I put quotes around the right hand side like so </p>
  
  <p>... "~/PATH_TO_APP/lib/parking_timer.sh STRING_VARIABLE"</p>
  
  <p>I get,</p>
  
  <blockquote>
    <p>-bash: ~/PATH_TO_APP/lib/parking_timer.sh STRING_VARIABLE: No such file or directory</p>
  </blockquote>
  
  <p>I I leave the quotes out, I get,</p>
  
  <blockquote>
    <p>at: garbled time</p>
  </blockquote>
  
  <p>This is all happening on a Mac OS 10.6 box running Rails 2.3 &amp; Ruby 1.8.6</p>
  
  <p>I've already messed around w/ BackgrounDrb, and decided its a total PITA.  I need to be able to cancel the job at any time before it is due.</p>