【发布时间】:2012-08-07 22:43:54
【问题描述】:
我需要帮助将系统命令的输出(stdin 和 stdout)发送到 bash 函数,同时仍接受来自参数的输入。类似于下面的示例。有人能指出我正确的道路吗?
LogMsg()
{
DateTime=`date "+%Y/%m/%d %H:%M:%S"`
echo '*****'$DateTime' ('$QMAKESPEC'): '$1 >> "$LogFile"
echo $DateTime' ('$QMAKESPEC'): '$1
}
# Already works
LogMsg "This statement is sent directly"
# Wish I could do this:
# Capture both stdout & stderr of a system function to the logfile
# I do not presume that any of the syntax that follows is good
make 2>&1 >(LogMsg)
【问题讨论】:
-
您还希望能够使用命令行参数调用
LogMsg吗?
标签: bash