Shell – How to use tee and logger -t “some tag:”

loggerpipeshelltee

I've seen in another post which shows how to use tee and logger as shown below.

tee >(logger) <<< "System Load is OK : $Current_loadadv"

>(logger) is bash syntax to create a file descriptor that is going to a FIFO, which is then fed to the standard input of logger (this is one form of what is known as "process substitution" in bash). It then passes back the path to that file descriptor as an argument to tee, and since tee writes to its non-option arguments, the FD is written to, and logger receives your string.

How can I modify the following command to use tag and logger above?

curl -Sks  http://x.x.x.x/scripts/somescript.sh | /bin/bash | logger -t "sometag"

Best Answer

Simply pipe bash to tee. Or did I misunderstand the problem?

root@el6 ~ # cat test.sh 
date

root@el6 ~ # cat test.sh | bash | tee >(logger -t "test")
Wed Jul 10 23:08:03 NZST 2013

root@el6 ~ # tail -n3 /var/log/messages
Jul 10 23:08:03 el6 test: Wed Jul 10 23:08:03 NZST 2013
Related Question