我正在将脚本重定向到日志
test.sh >> mylog
test.sh 有
spawn scp -o stricthostkeychecking=no /root/.ssh/id_rsa.pub
root@$IP:/root/.ssh/authorized_keys
我得到的日志为
spawn scp -o stricthostkeychecking=no /root/.ssh/id_rsa.pub root@IP:/root/.ssh/authorized_keys^M
Warning: Permanently added 'IP' (RSA) to the list of known hosts.^M^M
root@10.112.75.21's password: ^M
^Mid_rsa.pub 0% 0 0.0KB/s --:-- ETA^Mid_rsa.pub 100% 405 0.4KB/s 00:00 ^M
Host key verification failed.^M
Host key verification failed.^M
可能将 Control-M 添加到我的日志中的原因是什么?我在重定向时做错了什么吗?
谢谢你
PS:我所有的系统都是基于unix的系统
最佳答案
这是正常的。如果显示任何彩色字符,任何应用程序更改标题或在“全屏”模式下工作,您将得到更糟糕的 ANSI 序列(转义符,...)。
您可以使用 col
或 recode
来操作此类输出。
这可能是由于 ssh 的 -t 选项造成的。
关于linux - 在日志中提供 Control M 的重定向,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20352973/