如何最好地捕获和记录scp输出? [英] How to best capture and log scp output?
问题描述
我正在尝试从安装脚本(使用scp)捕获输出并将其记录下来.但是,我没有得到scp正在打印的所有内容,即进度条.
I am trying to capture output from an install script (that uses scp) and log it. However, I am not getting everything that scp is printing out, namely, the progress bar.
屏幕输出:
复制 /user2/cdb/builds/tmp/uat/myfiles/*至 将服务器/users/myfiles作为cdb
Copying /user2/cdb/builds/tmp/uat/myfiles/* to server /users/myfiles as cdb
cdb @ server的密码: myfile 100%| ***************************** || 2503 00:00
cdb@server's password: myfile 100% |*****************************| 2503 00:00
日志输出:
复制 /user2/cdb/builds/tmp/uat/myfiles/*至 将服务器/users/myfiles作为cdb
Copying /user2/cdb/builds/tmp/uat/myfiles/* to server /users/myfiles as cdb
我真的很想知道我的文件在那里.这是我现在尝试不起作用的内容:
I'd really like to know that my file got there. Here's what I am trying now to no avail:
myscript.sh 2>& 1 | tee mylogfile.log
myscript.sh 2>&1 | tee mylogfile.log
有人能捕获scp输出并将其记录吗?
Does anyone have a good way to capture scp output and log it?
谢谢.
推荐答案
似乎您只是从日志中丢失了scp是否成功.
It looks like your just missing whether the scp was succesful or not from the log.
我猜滚动条不能打印到stdout并使用ncurses或其他某种TUI?
I'm guessing the scroll bar doesn't print to stdout and uses ncurses or some other kind of TUI?
您只需查看scp的返回值即可查看它是否成功.像
You could just look at the return value of scp to see whether it was successful. Like
scp myfile user@host.com:. && echo success!
man scp
说
scp exits with 0 on success or >0 if an error occurred.
这篇关于如何最好地捕获和记录scp输出?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!