I tried a few different ways, I couldn't make this shell output work.
I tested .jar on ubuntu, when I run same code it works.
Not raising also any exception. It is a console application.
Looks like when I make shell call, application stops working. Never reaches to Log("Operation complete")
Please if anyone knows why ?
B4X:
Try
Dim shl As Shell
shl.Initialize("shl", "/usr/bin/mpstat", Array("-P","ALL"))
shl.Run(-1)
Wait For shl_ProcessCompleted (Success As Boolean, ExitCode As Int, StdOut As String, StdErr As String)
Log("done")
Log("Ecode:"&ExitCode)
Log("Error:"&StdErr)
Log("out:"&StdOut)
Log("Status:"&Success)
Catch
Log("Error execution")
Log(LastException)
End Try
Log("Operation complete")
I guess you are using Non-UI app, you need to do StartMessageLoop waiting for shl_ProcessCompleted .
Try this code
B4X:
Sub AppStart (Args() As String)
Dim shl As Shell
shl.Initialize("shl", "/usr/bin/mpstat", Array("-P","ALL"))
shl.Run(-1)
StartMessageLoop
End Sub
Sub shl_ProcessCompleted (Success As Boolean, ExitCode As Int, StdOut As String, StdErr As String)
Log("done")
Log("Ecode:"&ExitCode)
Log("Error:"&StdErr)
Log("out:"&StdOut)
Log("Status:"&Success)
Log("Operation complete")
StopMessageLoop
End Sub
I guess you are using Non-UI app, you need to do StartMessageLoop waiting for shl_ProcessCompleted .
Try this code
B4X:
Sub AppStart (Args() As String)
Dim shl As Shell
shl.Initialize("shl", "/usr/bin/mpstat", Array("-P","ALL"))
shl.Run(-1)
StartMessageLoop
End Sub
Sub shl_ProcessCompleted (Success As Boolean, ExitCode As Int, StdOut As String, StdErr As String)
Log("done")
Log("Ecode:"&ExitCode)
Log("Error:"&StdErr)
Log("out:"&StdOut)
Log("Status:"&Success)
Log("Operation complete")
StopMessageLoop
End Sub
Thanks, but It is not relating to that. StartmessageLoop only wait main thread, but i call it with wait for to collect output and return, also your method with fail. I have various calls.
Thanks, but It is not relating to that. StartmessageLoop only wait main thread, but i call it with wait for to collect output and return, also your method with fail. I have various calls.