I am trying to understand a codebase where I see a line like below:
socat /tmp/haproxy - <<< "show servers state" > /var/state/haproxy/global
What is socat doing here? What does <<<
mean?
I am trying to understand a codebase where I see a line like below:
socat /tmp/haproxy - <<< "show servers state" > /var/state/haproxy/global
What is socat doing here? What does <<<
mean?
The
socat
command creates a bidirectional pipe between the file/tmp/haproxy
andstdin
which is expressed by passing-
tosocat
.In fact it appends stdin to
/tmp/haproxy
and writes the resulting output to/var/state/haproxy/global
<<<
is a bash feature, a so called here string. It passes the string "show server state" as stdin tosocat
.A posix shell version would be:
<<<
is a bashism to put a string on stdinThe
man
pages of thesocat
command andbash
may help (Note that<<<
is a bash feature)Try: