将DOS的期望输出实时转换为UNIX样式 [英] Convert expect output from DOS to UNIX style in realtime

查看:101
本文介绍了将DOS的期望输出实时转换为UNIX样式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我通过串行连接连接到远程主机来编写一些期望脚本.

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

我的问题是,生成的进程(使用log_user 1启用)的输出包含DOS样式的结尾(当在VIM中读取日志时,每行以^M终止).

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).

我通常在期望会话结束时在所有日志上运行dos2unix,以摆脱它们.转换可以实时完成吗?

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?

推荐答案

事实证明,问题确实很简单.

It turned out the problem is really simple.

我对脚本所做的工作是按如下方式调用它们:

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

expect script.exp > mylog

如描述中所述,mylog在Vim中打开或使用cat -v mylog时包含^M行尾.

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

这篇关于将DOS的期望输出实时转换为UNIX样式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆