Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
481 views
in Technique[技术] by (71.8m points)

windows - 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.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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%"

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...