arzyfex arzyfex - 1 year ago 112
Linux Question

at command in ruby script

I am having simple ruby script which will send mail after certain time, this is my code :

#!/usr/bin/env ruby
system("at now + 1 day <<END
echo 'This is test message from xyz' | mail -s 'Test message'

whenever I run this script, I get

sh: END: not found

Edit 1

If I use on single line like

system("at now + 1 min echo 'This is test message from xyz' | mail -s 'Test message'")

it gives error :

syntax error. Last token seen: e

Garbled time

what am doing wrong in this ?

Answer Source

The at one-liner form can be like echo 'COMMAND' | at WHEN.

You can try this:

system("echo \"echo 'This is test message from xyz' | mail -s 'Test message'\" | at now + 1 day")
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download