B4J Question jShell running python scripts on Raspberry Pi

walterf25

Expert
Licensed User
Longtime User
I'm experimenting trying to run some shell scripts and python scripts on my raspberry pi 3.
i'am working with a UI application.

I've followed several threads i've found in the forums but have not been able to get anything working.

For example i have the following code and while i don't get any errors or get any crashes, I can also see the ProcessCompleted sub completing with a success flag but i don't see anything at the output (stdOut).

B4X:
    sh.Initialize("sh", "python", Array As String("./ble_log.py")
    sh.WorkingDirectory = "/home/pi/nrf_shell/input_stream/"   'path where ble_log.py file is located
    sh.Run(-1)

The python scripts basically begins a scan for BLE devices and outputs the device names and Mac-Addresses along with each device's signal strength continously, I know the script works because if I execute it directly from the command line in my raspberry pi i can see all the nearby devices being printed in the console.
Is there anything i may be missing, sometimes i also get a pop up window with the error: "Child process could not be started" but i believe this is a different issue.
All i need to be able to do is execute the python script and be able to read the output in the processcompleted function.

Hope someone can point me in the right direction.

Thanks,
Walter
 

walterf25

Expert
Licensed User
Longtime User
What about StdErr?

What happens when you run this command from the terminal?
I don't get any errors in StdErr, if i run the command from the terminal it works fine, as i mentioned on my post i can see all the nearby devices being logged in the terminal continuously.

Walter
 
Upvote 0

Roycefer

Well-Known Member
Licensed User
Longtime User
One possible solution: if your Python script is run with sudo, then your Java app that calls it must also be run with sudo.
 
Upvote 0

walterf25

Expert
Licensed User
Longtime User
One possible solution: if your Python script is run with sudo, then your Java app that calls it must also be run with sudo.
I don't think the python script is being called with sudo, but just to test this out, how do i run the java app with sudo? I'm basically running the app through b4j-bridge.

Thanks,
Walter
 
Upvote 0

walterf25

Expert
Licensed User
Longtime User
Try starting b4j-bridge with sudo like so:
B4X:
sudo java -jar b4j-bridge.jar
Ah you mean that, yes I am already doing that, I doubt that's the issue.

Walter
 
Upvote 0
Top