2016-12-25 5 views
1

にリダイレクトする方法はありますか?bashスクリプトから新しいバックグラウンドプロセスを生成し、現在のスクリプトのstdout/stderrをfdリダイレクトを使用してそのプロセスのstdinにリダイレクトするにはどうすればよいですか?名前付きパイプや一時ファイルの使用、coprocsの使用、サブシェルでのスクリプト全体の実行、それを他のプロセスにリダイレクトするなど、同じ効果を達成するためのいくつかの方法を知っていますが、私は探しています同じ方法で、私はこれを行うことができます:exec 2>&1スクリプト内からの単純な1行のIOリダイレクション。基本的に、私はこのような何か(プロセスが生み出されている方法は、もちろん変更することができます)をやりたい:プロセスを起動し、現在のbashスクリプトの出力を

#!/bin/bash 
# Redirect stdout/stderr of current process to stdin of spawned process 
# The >() syntax evaluates to a file descriptor that is connected 
# to the new process's stdin 
exec &> >(zenity --text-info) 
:私はこの使用してプロセスへの置換解決策を見つけた
#!/bin/bash 
zenity --text-info & # The process to receive this script's output 
# Do something to redirect this shell's stdout 
# to the background process's stdin 
echo "something" # This should be read by the background process 

答えて

関連する問題