Convert expect output from DOS to UNIX style in realtime

本秂侑毒 提交于 2019-12-25 05:32:18

问题


I write some expect scripts by connecting to a remote host through serial connection.

My problem is that the output of the spawned process (enabled with log_user 1) contains DOS-style endings (each line being terminated with ^M when reading logs in VIM).

I normally run dos2unix on all logs at the end of the expect session, to get rid of them. Can the conversion be done in real time?


回答1:


It turned out the problem is really simple.

What I am doing with my scripts is calling them like below:

expect script.exp > mylog

As told in the description, mylog contains ^M line-endings when opened in Vim or using cat -v mylog.

To get rid of them in real-time, I just call now:

expect script.exp | tr -d '\r' > mylog


来源:https://stackoverflow.com/questions/30786082/convert-expect-output-from-dos-to-unix-style-in-realtime

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