【发布时间】:2012-08-22 14:36:33
【问题描述】:
我正在寻找一种解决方案(类似于下面的 bash 代码),除了 Solaris 上的 ksh 中的屏幕之外,还可以将 stdout 和 stderr 复制到一个文件中。
以下代码在 bash shell 中运行良好:
#!/usr/bin/bash
# Clear the logfile
>logfile.txt
# Redirect all script output to a logfile as well as their normal locations
exec > >(tee -a logfile.txt)
exec 2> >(tee -a logfile.txt >&2)
date
ls -l /non-existent/path
由于某种原因,这会在 Solaris 上引发语法错误。我认为这是因为我无法进行进程替换,并且我看到一些帖子建议使用 mkfifo,但我还没有想出一个可行的解决方案。
有谁知道除了默认位置之外,所有输出都可以重定向到文件的方法吗?
【问题讨论】:
标签: shell ksh io-redirection