[英]bash script is stuck at tee
我正在使用两个脚本说script1
和script2
。 我从生成大量文本数据的script1
调用script2
。 我正在使用 tee 将此文本重定向到一个文件。 但是 tee 卡住了,没有前进。
我无法给出确切的示例,因为脚本太长,无法包含在此处。 因此,请简要介绍正在发生的事情。
# script1
# Do some task
/bin/bash script2.sh 2>&1 | tee script2.log
capture=$(cat script2.log | grep "Successfully completed" | wc -l)
# Do some more work
#script2
# Execute some code
# Some python scripts
echo "Script End here"
现在,当我执行script1.sh
时,我在Script End here
表示第二个脚本已成功完成。 但是 script1 卡在tee
。 当我移除tee
并且没有捕获 output 时,它运行良好。
有没有人遇到过这种情况。 任何想法可能会发生什么。
# System details
$ uname -a
Linux jetson-nx-jetpack461 4.9.253-tegra #1 SMP PREEMPT Sat Feb 19 08:58:27 PST 2022 aarch64 aarch64 aarch64 GNU/Linux
# Bash version
$ bash --version
GNU bash, version 4.4.20(1)-release (aarch64-unknown-linux-gnu)
Copyright (C) 2016 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software; you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
来自script2
当脚本有大量行(1000/2000/...)时,很难使用set -x
进行调试。
要么根据 Barmar 的评论继续,要么包括:
echo read1 read command12 echo read2 read command23
查看它悬挂的位置。
如果它恰好由于 tee 而挂起,请使用以下命令:
echo read5 read echo type tee type tee echo read6 read
使用它,我们可以准确地确定脚本挂在哪里。
调试时也可以使用read1.1 read1.0 read1.-1...。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.