我有一个简单的 ruby 脚本,它会在一定时间后发送邮件,这是我的代码:
#!/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")
每当我运行这个脚本时,我都会得到
sh: END: not found
编辑 1
如果我像这样在单行上使用
system("at now + 1 min echo 'This is test message from xyz' | mail -s 'Test message' someone@example.com")
它给出错误:
syntax error. Last token seen: e
Garbled time
这里做错了什么?
最佳答案
at
单行形式可以像 echo 'COMMAND' |在什么时候
。
你可以试试这个:
system("echo \"echo 'This is test message from xyz' | mail -s 'Test message' someone@example.com\" | at now + 1 day")
关于ruby - 在 ruby 脚本中的命令,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37544522/