# Basic functionality of RunThrough

The documentation for RunThrough["command",expr] says that it executes an external command and returns the result. Does that mean it executes it as if on the command line? Why does this not return the string "blah" (or maybe "blah\r\n")?

RunThrough["echo","blah"]


(I'm on Windows.)

• @Mr.Wizard. I still think echo writes to Window's equivalent of stdout. – m_goldberg Feb 8 '17 at 3:22
• Given the way RunThrough works, the expression that will give you the behavior you expect is RunThrough["cat", "blah"] – m_goldberg Feb 8 '17 at 5:57

That

RunThrough["echo", "blah"]


doesn't work appears strange because on my system, OS X, which means the terminal command line is talking to Free BSD Unix, man echo gives

echo -- write arguments to the standard output

Further, both

RunThrough["cat", "blah"]


and

RunThrough["echo blah", ""]


work.

### Update

It turns out the operative phrase in my quote from the Unix man page is "write arguments". That is, echo does not accept input from standard input. It only writes the arguments that follow the token echo on the command line to standard output. The documentation for RunThrough says the second argument is passed to the OS command mentioned in the first argument by standard input. I assume this means pipped in.

This explains the behavior encountered by the OP and why RunThrough["echo blah", ""] works.

• RunThrough["echo blah", ""] works on Windows too. +1 and disregard my earlier comments. (I'll delete them later after people have had ample chance to see and laugh at them. :o) – Mr.Wizard Feb 8 '17 at 3:29
• So it was the input channel rather than the output channel that was the problem. Thanks for tracking that down. – Mr.Wizard Feb 8 '17 at 6:22
• @Mr.Wizard. Yes – m_goldberg Feb 8 '17 at 9:36