Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I use a pipe to redirect the output of one command to the input of another?

I have a program which sends text to an LED sign.

prismcom.exe

To use the program to send "Hello":

prismcom.exe usb Hello 

Now, I wish to, for example use a command program called Temperature.

temperature 

Let's say the program gives your computer's temperature.

Your computer is 100 degrees Fahrenheit. 

Now, I wish to write the output of temperature to prismcom.exe:

temperature | prismcom.exe usb 

This does not seem to work.

Yes, I've looked for a solution to this for more than twenty minutes. In all cases, they are either kludges/hacks or a solution for something besides the Windows command line.

I would appreciate direction as to how I would pipe the output from temperature to prismcom.

Thanks!

Edit: Prismcom has two arguments. The first will always be 'usb'. Anything that comes after that will be displayed on the sign.

like image 830
Austin Burk Avatar asked Jan 29 '13 01:01

Austin Burk


People also ask

Can the pipe symbol be used to redirect the output from one command to another?

A pipe is a form of redirection (transfer of standard output to some other destination) that is used in Linux and other Unix-like operating systems to send the output of one command/program/process to another command/program/process for further processing.

Which command is used to pipe the output of a command to the input of another command?

Summary: Pipes '|' send the output of one command as input of another command.

How do I redirect output to input?

On a command line, redirection is the process of using the input/output of a file or command to use it as an input for another file. It is similar but different from pipes, as it allows reading/writing from files instead of only commands. Redirection can be done by using the operators > and >> .

Which character is used to pipe output from one command to another?

The pipe character | is used to connect the output from one command to the input of another. > is used to redirect standard output to a file. Try it in the shell-lesson-data/exercise-data/proteins directory!


1 Answers

Try this. Copy this into a batch file - such as send.bat - and then simply run send.bat to send the message from the temperature program to the prismcom program.

temperature.exe > msg.txt set /p msg= < msg.txt prismcom.exe usb "%msg%" 
like image 76
Kenny Kerr Avatar answered Sep 28 '22 23:09

Kenny Kerr