M
M
Misha Shav2020-02-14 09:49:47
Command line
Misha Shav, 2020-02-14 09:49:47

How to process command line response by standard means?

Subject: Is it possible to read command line responses using cmd/PS? More specifically, software that works from the command line?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
V
Vadim Priluzkiy, 2020-02-14
@SeanCooper

program > file
program > file 2>&1
program | program2
program | program2 2>&1

1. The standard output of the redirect command to a file.
2. Standard output and error output redirect to a file.
3. Send the standard output of the program to the standard input of program2, for processing.
4. Send standard output and error output to program2 input for processing.

R
res2001, 2020-02-14
@res2001

Usually, to process the output of commands in a batch file, they drive the command into a loop of the form:

for /f "tokens=xxx delims=yyy" %%a in ('тут нужная команда') do (
   echo %%a
)

and inside the loop access the output of the command line by line.
You can split output lines into tokens, set token separators, skip lines at the beginning using the loop parameters (specified in quotes).
For reference seefor /?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question