shell 使用sed传递命令

gblwokeq  于 2023-01-21  发布在  Shell
关注(0)|答案(1)|浏览(135)

我使用一些命令作为runcmd作为用户数据:

[ sh, -c, 'echo "sendmail: ALL" >> /etc/hosts.allow' ]
[ sh, -c, 'systemctl restart sendmail' ]
[ sh, -c, 'echo "Subject: Instance Deployed" | sendmail /user@example.com/' ]

我想添加sendmail:ALL to etc/hosts.allow并发送带有主题行的电子邮件。
但是,当我手动尝试这些步骤时,我收到了电子邮件,并且能够编辑文件。
请给我提个建议我哪里做错了。
尝试

[ sh, -c, 'echo "sendmail: ALL" >> /etc/hosts.allow' ]

但发送邮件:ALL未添加到etc/hosts.allow

2vuwiymt

2vuwiymt1#

简而言之:

echo "sendmail: ALL" >> /etc/hosts.allow

正如KamilCuk所说,从每行中删除[ sh, -c, '' ]

相关问题