Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/fsharp/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Linux 避免bash脚本等待用户输入enter键_Linux_Bash_Unix_Mailx - Fatal编程技术网

Linux 避免bash脚本等待用户输入enter键

Linux 避免bash脚本等待用户输入enter键,linux,bash,unix,mailx,Linux,Bash,Unix,Mailx,我在bash脚本中得到以下条目 echo "Please see attached file" | mailx -S smtp=$smtpServer -s "Subject of the mail" -a $logfile -r "sender@domain.com" receiver1@domain.com receiver2@domain.com 如果在发送邮件时没有错误,它就可以正常工作。但有时如果出现错误,mailx将显示错误消息并等待用户输入enter键(回车)。我想避免这种情况

我在bash脚本中得到以下条目

 echo "Please see attached file" | mailx -S smtp=$smtpServer -s "Subject of the mail" -a $logfile -r "sender@domain.com" receiver1@domain.com receiver2@domain.com

如果在发送邮件时没有错误,它就可以正常工作。但有时如果出现错误,mailx将显示错误消息并等待用户输入enter键(回车)。我想避免这种情况。它不应该等待用户输入enter键。如何在bash脚本中实现这一点

您可以使用expect命令查找匹配的文本,并将值设置为输入。这将在看到文本时自动键入值

以下问题的解决方案可能有用。

另请参阅。

将本地邮件服务器配置为$smtpServer的中继。