33313

What does

Question:

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?

Answer1:

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 <a href="https://www.gnu.org/software/bash/manual/bashref.html#Here-Strings" rel="nofollow"><em>here string</em></a>. It passes the string "show server state" as stdin to socat.

Answer2:

A posix shell version would be:

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

<<< is a bashism to put a string on stdin

Answer3:

The man pages of the socat command and bash may help (Note that <<< is a bash feature)

Try:

man socat man bash # Type the following when the bash man page is open # it will point you right to the explanation of <<< /<<<

Recommend

  • Python multiprocessing pipe will not recv() properly
  • how change text direction(not paragraph alignment) in document in apache poi word?(XWPF)
  • unicode table information about a character in python
  • Pattern ^u.meta(\\.|$) not working as expected
  • Environment is not passed to process opened by proc_open
  • having a map of strings how to compare it to given string
  • Line buffered reading in Perl
  • Understand pipe and redirection command
  • Python Pandas: Adding methods to class pandas.core.series.Series
  • Redirect stdout of one process to two processes
  • how do you “Press ENTER to continue, anything else to quit” in C++
  • How to invoke script that uses scan() on Windows?
  • How to get a list of all blobs in a repository in Git
  • Extract and multiple integers from user-input string in Ruby?
  • Can TextIO write to prefixes derived from the window maxTimestamp?
  • Git cherry-Pick a batch of commits from a file
  • console.log printing statements in the wrong order for learnyounode node.js tutorial
  • Substitution Method - How to find two tags with a newline inbetween using Perl?
  • Get the followers on a post efficient way in laravel 5.1
  • Replicating and differentiating portions of a form
  • Read stdin in chunks in Bash pipe
  • System call time out?
  • Determining the length of a read stream in node js
  • How can I count unique terms in a plaintext file case-insensitively?
  • Converter from SAT to 3-SAT
  • Interpreting STRACE output - pipes and forks
  • How to read piped content in C?
  • Bigquery event streaming and table creation
  • Cannot upload to OneDrive using the new SDK
  • Change Inet root folder for iis 7
  • Jenkins: How To Build multiple projects from a TFS repository?
  • What is the “return” in scheme?
  • How do I fake an specific browser client when using Java's Net library?
  • Apache 2.4 - remove | delete | uninstall
  • Run Powershell script from inside other Powershell script with dynamic redirection to file
  • Load html files in TinyMce
  • How can I get HTML syntax highlighting in my editor for CakePHP?
  • What are the advantages and disadvantages of reading an entire file into a single String as opposed
  • coudnt use logback because of log4j
  • How to get NHibernate ISession to cache entity not retrieved by primary key