i got following entry in a bash script.
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
Its working fine if there is no error in sending mail. but sometimes if there is an error ,mailx will show the error message and wait for user to enter the enter key(carriage return).I want to avoid this.it should not wait for user to enter the enter key . how to do it in bash script ?
You can use expect command to look for matching text and set the value to be key-in. This will automatically keyin the value when it sees the text.
Solution to the below question might be useful. Linux - Bash & Expect
Also please refer. http://sharadchhetri.com/2010/12/07/how-to-use-expect-in-bash-script/
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.