1

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?

4

3 回答 3

3

The socat command creates a bidirectional pipe between the file /tmp/haproxy and stdin which is expressed by passing - to socat.

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 to socat.

于 2016-03-16T14:04:32.040 回答
1

posix shell 版本将是:

echo "show servers state" | socat /tmp/haproxy - > /var/state/haproxy/global

<<<是在标准输入上放一个字符串的基础

于 2016-03-16T14:11:00.773 回答
0

该命令的man页面可能会有所帮助(请注意,这是一个 bash 功能)socatbash<<<

尝试:

man socat
man bash
# Type the following when the bash man page is open
# it will point you right to the explanation of <<<
/<<<  
于 2016-03-16T13:42:53.463 回答