How do I create a decent bash script to start an ETRN on a mail-server?

笑着哭i 提交于 2020-06-17 09:18:07

问题


Once in a while, I need to ETRN a couple of backup servers (e.g. after maintenance of my own SMTP server). Normally, I use telnet for that. I go to that server, HELO with my own name and give the ETRN commands. I would like to automate that in a decent way. A simple (but not decent) way would be to start telnet with <<, but the problem is that I do not want to send commands out of order (and the other end may even drop the connection if I do that, haven't tested it yet, but if it works now, it may not work anymore later so I'd like a decent solution and not one that may break later). E.g., I want to wait for the 220 line from the remote SMTP server, then send my HELO, wait for the 250 reply, and only then send the various ETRN commands. How do I do that in bash? Or do I need to use something else, such as python?

来源:https://stackoverflow.com/questions/60352522/how-do-i-create-a-decent-bash-script-to-start-an-etrn-on-a-mail-server

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!