Hi,
I would like to execute some commands with JProc library and meet some problem, after studied the tutorial still can't get the solution, so ask some help here.
My command is simple with some pipes, for example,
the simple command is:
# adb devices
List of devices attached
emulator-5554 device
and then I would like to add one pipe:
#adb devices | tail -n +1
emulator-5554 device
and then finally I would like to add more one pipe:
#adb devices | tail -n +2 | awk '{print $1}'
emulator-5554
so my script is:
ByteArrayOutputStream output = new ByteArrayOutputStream();
ProcResult result = new ProcBuilder("adb")
.withArgs("devices")
.withOutputStream(output).run();
System.out.println(output.toString());
new ProcBuilder("tail")
.withArgs("-n", "+2")
.withOutputStream(output)
.run();
System.out.println(output.toString());
new ProcBuilder("awk")
.withArgs("'{print $1}'")
.withOutputStream(output)
.run();
System.out.println(output.toString());
it doesn't work.
and also
ByteArrayOutputStream output = new ByteArrayOutputStream();
ProcResult result = new ProcBuilder("adb")
.withArgs("devices")
.withOutputConsumer(stream -> new ProcBuilder("tail")
.withArgs("-n", "+2")
.withOutputConsumer(stream1 -> {
new ProcBuilder("awk")
.withArgs("'{print $1}'")
.withOutputStream(output).run();
}).run())
.run();
System.out.println(output.toString());
it also doesn't work.
Could you help to provide some solution for my question?
Thanks.
Hi,
I would like to execute some commands with
JProclibrary and meet some problem, after studied the tutorial still can't get the solution, so ask some help here.My command is simple with some pipes, for example,
the simple command is:
# adb devices List of devices attached emulator-5554 deviceand then I would like to add one pipe:
#adb devices | tail -n +1 emulator-5554 deviceand then finally I would like to add more one pipe:
#adb devices | tail -n +2 | awk '{print $1}' emulator-5554so my script is:
it doesn't work.
and also
it also doesn't work.
Could you help to provide some solution for my question?
Thanks.