arzyfex arzyfex - 6 months ago 28
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' someone@example.com
END")


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' someone@example.com")


it gives error :


syntax error. Last token seen: e

Garbled time


what am doing wrong in this ?

Answer

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' someone@example.com\" | at now + 1 day")
Comments