Rahul
Rahul

Reputation: 420

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' [email protected]
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' [email protected]")

it gives error :

syntax error. Last token seen: e

Garbled time

what am doing wrong in this ?

Upvotes: 0

Views: 198

Answers (1)

delta
delta

Reputation: 3818

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' [email protected]\" | at now + 1 day")

Upvotes: 4

Related Questions