Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 691525
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T02:33:12+00:00 2026-05-14T02:33:12+00:00

I’m trying to setup a simple timer that gets started from a Rails Application.

  • 0

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.

Here’s my test lines in Rails

output = `at #{(Time.now + 60).strftime("%H:%M")} < #{Rails.root}/lib/parking_timer.sh STRING_VARIABLE`
return render :text => output

Then my parking_timer.sh looks like this

#!/bin/sh               
~/PATH_TO_APP/script/runner -e development ~/PATH_TO_APP/lib/ParkingTimer.rb $1
echo "All Done"    

Finally, ParkingTimer.rb reads the passed variable with

ARGV.each do|a|
   puts "Argument: #{a}"
end

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

If I put quotes around the right hand side like so

… “~/PATH_TO_APP/lib/parking_timer.sh STRING_VARIABLE”

I get,

-bash: ~/PATH_TO_APP/lib/parking_timer.sh STRING_VARIABLE: No such file or directory

I I leave the quotes out, I get,

at: garbled time

This is all happening on a Mac OS 10.6 box running Rails 2.3 & Ruby 1.8.6

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.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-14T02:33:12+00:00Added an answer on May 14, 2026 at 2:33 am

    After playing around with irb a bit, here’s what I found.

    The backtick operator invokes the shell after ruby has done any interpretation necessary. For my test case, the strace output looked something like this:

    execve("/bin/sh", ["sh", "-c", "echo at 12:57 < /etc/fstab"], [/* 67 vars */]) = 0   
    

    Since we know what it’s doing, let’s take a look at how your command will be executed:

    /bin/sh -c "at 12:57 < RAILS_ROOT/lib/parking_timer.sh STRING_VARIABLE"
    

    That looks very odd. Do you really want to pipe parking_timer.sh, the script, as input into the at command?

    What you probably ultimately want is something like this:

    /bin/sh -c "RAILS_ROOT/lib/parking_timer.sh STRING_VARIABLE | at 12:57"
    

    Thus, the output of the parking_timer.sh command will become the input to the at command.

    So, try the following:

     output = `#{Rails.root}/lib/parking_timer.sh STRING_VARIABLE | at #{(Time.now + 60).strftime("%H:%M")}`
    return render :text => output
    

    You can always use strace or truss to see what’s happening. For example:

    strace -o strace.out -f -ff -p $IRB_PID
    

    Then grep '^exec' strace.out* to see where the command is being executed.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 382k
  • Answers 382k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer You could use new GregorianCalendar(theYear, theMonth, theDay).getTime(): public GregorianCalendar(int year,… May 14, 2026 at 10:39 pm
  • Editorial Team
    Editorial Team added an answer I think your code should be; my $self = {… May 14, 2026 at 10:39 pm
  • Editorial Team
    Editorial Team added an answer You could just show/hide a control for a certain period… May 14, 2026 at 10:39 pm

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.