Mark Read Well-Known Member Licensed User Longtime User Jan 11, 2016 #1 I am using a tablet running a B4A app connecting via Bluetooth to an Raspberry Pi running a B4J app headless. My question, how can I send a command to the Pi to shutdown the Pi? Many thanks.
I am using a tablet running a B4A app connecting via Bluetooth to an Raspberry Pi running a B4J app headless. My question, how can I send a command to the Pi to shutdown the Pi? Many thanks.
Erel B4X founder Staff member Licensed User Longtime User Jan 11, 2016 #2 You can use jShell to execute the shutdown command. http://www.computerhope.com/unix/ushutdow.htm Upvote 0
jayel Active Member Licensed User Longtime User May 2, 2016 #3 Hello, Did you manage to execute the shutdown command? If Yes, how did you do it? Greets John Upvote 0
Mark Read Well-Known Member Licensed User Longtime User May 2, 2016 #4 jayel said: Did you manage to execute the shutdown command? Click to expand... Sorry, got waylaid with other parts of my app and had no time to try a solution. Shouldn't be too difficult to send "shutdown now" via jShell. Upvote 0
jayel said: Did you manage to execute the shutdown command? Click to expand... Sorry, got waylaid with other parts of my app and had no time to try a solution. Shouldn't be too difficult to send "shutdown now" via jShell.
jayel Active Member Licensed User Longtime User May 2, 2016 #5 OK I made a sh script on my raspberry Code: #!/bin/sh sudo shutdown -h now I execute my script like this on B4J program : Code: Sub Shutdown Dim myshell As Shell myshell.Initialize("shl","shutdown.sh",Null) myshell.WorkingDirectory = "/home/pi/telmachine/" myshell.Run(10000) End Sub When I try to execute I get this error Error: org.apache.commons.exec.ExecuteException: Execution failed (Exit value: -559038737. Caused by java.io.IOException: Cannot run program "shutdown.sh" (in directory "/home/pi/telmachine"): error=2, Bestand of map bestaat niet) Click to expand... Upvote 0
OK I made a sh script on my raspberry Code: #!/bin/sh sudo shutdown -h now I execute my script like this on B4J program : Code: Sub Shutdown Dim myshell As Shell myshell.Initialize("shl","shutdown.sh",Null) myshell.WorkingDirectory = "/home/pi/telmachine/" myshell.Run(10000) End Sub When I try to execute I get this error Error: org.apache.commons.exec.ExecuteException: Execution failed (Exit value: -559038737. Caused by java.io.IOException: Cannot run program "shutdown.sh" (in directory "/home/pi/telmachine"): error=2, Bestand of map bestaat niet) Click to expand...
Mark Read Well-Known Member Licensed User Longtime User May 2, 2016 #6 just a thought. Not able to try it. Code: Sub Shutdown Dim myshell As Shell myshell.Initialize("myshell","shutdown.sh",Null) myshell.WorkingDirectory = "/home/pi/telmachine/" myshell.Run(-1) End Sub Upvote 0
just a thought. Not able to try it. Code: Sub Shutdown Dim myshell As Shell myshell.Initialize("myshell","shutdown.sh",Null) myshell.WorkingDirectory = "/home/pi/telmachine/" myshell.Run(-1) End Sub
jayel Active Member Licensed User Longtime User May 2, 2016 #7 Code: Sub Shutdown Dim myshell As Shell myshell.Initialize("shl","sh",Array as string("shutdown.sh")) myshell.WorkingDirectory = "/home/pi/telmachine/" myshell.Run(10000) End Sub That was the solution ! Upvote 0
Code: Sub Shutdown Dim myshell As Shell myshell.Initialize("shl","sh",Array as string("shutdown.sh")) myshell.WorkingDirectory = "/home/pi/telmachine/" myshell.Run(10000) End Sub That was the solution !