在Ruby中调用系统时计算变量

在Ruby中调用系统时计算变量,ruby,system-calls,ruby-1.9.3,Ruby,System Calls,Ruby 1.9.3,我想在Ruby echo "<html><body><b>BOLD</b></body></html>" | mutt -e "set content_type=text/html" -s "HTML content" -- anushka.misra2@gmail.com 现在,我希望电子邮件成为一个变量: email = anushka.misra2@gmail.com system 'echo "<html&

我想在
Ruby

echo "<html><body><b>BOLD</b></body></html>" | mutt -e "set content_type=text/html" -s "HTML content"  -- anushka.misra2@gmail.com
现在,我希望电子邮件成为一个变量:

email = anushka.misra2@gmail.com
system 'echo "<html><body><b>BOLD</b></body></html>" | mutt -e "set content_type=text/html" -s "HTML content"  -- $email'
email=anushka。misra2@gmail.com
系统'echo“BOLD”| mutt-e“set content_type=text/html”-s“html content”-$email'
但这失败了,因为它没有计算电子邮件变量。如何修复它?

system%Q{echo“BOLD”| mutt-e“set content_type=text/html”-s“html content”--#{email}
system %Q{echo "<html><body><b>BOLD</b></body></html>" | mutt -e "set content_type=text/html" -s "HTML content"  -- #{email}}
#{foo}
是向字符串中添加值的Ruby方法<代码>{foo}仅在带有
(而不是
)的字符串中求值。其中
%Q{}
执行相同的操作,但不必在字符串中转义

system %Q{echo "<html><body><b>BOLD</b></body></html>" | mutt -e "set content_type=text/html" -s "HTML content"  -- #{email}}