我需要檢查我的程序輸出是否被重定向;如果是的話,我需要保留並通過郵件發送。檢查bash腳本中是否存在stdout重定向
例如:
$ myprogram -param1 -param2 -param3 > /home/polly/log.txt
myprogram.sh
:
if 'redirection is not empty'; then
cat <redirection name> | mailx -s "This is a test email." [email protected]
fi
我不知道我的理解。如果被稱爲'myprogram> something',你想郵寄'something'的內容? – 2014-11-05 16:08:19
你可以問一個問題。 – Steffen 2014-11-05 16:21:12
正確,我想保持someting併發送到正文消息 – JackFrost65 2014-11-05 16:24:32