5

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"
0

1 Answer 1

11

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
4
  • 4
    don't need bash just use cat test.sh | tee >(logger -t "test") Jul 11, 2013 at 6:45
  • @RahulPatil - I guess he needs bash there because he wants to download and execute the script in one go.
    – MLu
    Jul 11, 2013 at 9:07
  • may be.. I have not tested.. Jul 11, 2013 at 9:18
  • 1
    Can anyone describe how it works? I thought tee is printing to stdout and to a specified file, but here the file is not specified and stdout is redirected to logger. Jul 20 at 12:29

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .