Somehow I don't find a sufficient answer to my problem, only parts of hackarounds.
I'm calling a single "chained" shell command (from a Node app), that starts a long-running update process, which it's stdout/-err should be handed over, as arguments, to the second part of the shell command (another Node app that logs into a DB).
I'd like to do something like this:
updateCommand 2>$err 1>$out ; logDBCommand --log arg err out
>
as it is only for files or file descriptors.error=$( { updateCommand | sed 's/Output/tmp/'; } 2>&1 ); logDBCommand --log arg \"${error}.\"
), I can only have stdout or both mixed into one argument.答案 0 :(得分:1)
在#!/bin/bash中进行一些聊天后,有人建议只使用tpmsf(RAM中保存的文件系统),这是第二种最优雅(但唯一可能)的方法。因此,我可以使用>
运算符,并在内存中的单独变量中使用stdout
和stderr
。
command1 >/dev/shm/c1stdout 2>/dev/shm/c1stderr
A=$(cat /dev/shm/c1sdtout)
B=$(cat /dev/shm/c1stderr)
command2 $A $B
(或更短):
A=$(command1 2>/dev/shm/c1stderr )
B=$(cat /dev/shm/c1stderr)
command2 $A $B