O
O
Oleg Gamega2015-10-27 18:33:29
Java
Oleg Gamega, 2015-10-27 18:33:29

How to work with console programs from code?

Hello.
A bit of a stupid question, but still ─ I haven’t written for a detscope for a very long time, I wouldn’t want to produce bicycles.
How to work with console programs from code?
For example, get a list of connected android devices using the adb utility

>adb devices
List of devices attached
SH262TV02082	device

will run the adb devices command and get the string
List of devices attached
SH262TV02082	device

the question is 15 minutes with Google, do I understand correctly what's next just to parse?
How do you usually write software that works with other software?
Of course, the questions are stupid, but they are spoiled by andorid development, where such tasks are solved with the help of providers and the result is immediately ready for use) I intuitively expect something similar from the detscope and do not want to produce bicycles))
Thank you in advance.

Answer the question

In order to leave comments, you need to log in

3 answer(s)
Z
Zelimkhan Beltoev, 2015-10-27
@Beltoev

Alas, you still have to cycle.
In the sense that you run a console program, redirect its output to your stream, and this output is already stupidly parsed

M
MiiNiPaa, 2015-10-27
@MiiNiPaa

Use popen / _popen.
https://msdn.microsoft.com/en-us/library/96ayss4b.aspx
linux.die.net/man/3/popen

S
SerJook, 2016-01-07
@SerJook

doc.qt.io/qt-5/qprocess.html

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question