我试图将现有的bash脚本移植到Solaris和FreeBSD上。它在Fedora和Ubuntu上运行良好。与脚本程序相关的bash脚本移植问题
此bash脚本使用以下命令集将输出刷新到临时文件。
file=$(mktemp)
# record test_program output into a temp file
script -qfc "test_program arg1" "$file" </dev/null &
脚本程序在FreeBSD和Solaris上没有-qfc选项。在Solaris和FreeBSD上,脚本程序只有-a选项。我做了以下工作直到现在:
1)更新到最新版本的bash。这没有帮助。
2)试着找出“脚本”程序源代码的确切位置。我也找不到它。
有人可以帮我吗?
https://git.kernel.org/pub/scm/utils/util-linux/util-linux.git/tree/term-utils/ script.c – melpomene
为什么需要用'script'来捕获输出?通常,该程序用于交互式会话。如果您只想捕获stdout和stderr,请改用'>“$ file”2>&1'。 – ceving
我认为程序的输出没有立即刷新。这就是为什么脚本程序正在被使用。 –