B4J Question How would I query a Pi service to check that a specific one is running?

Discussion in 'B4J Questions' started by paddy12309, Jun 17, 2019.

  1. paddy12309

    paddy12309 Member

    New to B4J!
    Need to check a specific service is running,

    Dim shl_DHCP As Shell
    shl_DHCP.Initialize("shl_DHCP", "sudo ", Array As String("service", "--status-all","|", "grep","isc-dhcp-server","|","grep","+"))
    shl_DHCP.Run(10000) 'set a timeout of 10 seconds

    I am getting errors until I remove from (and including) the first pipe?
    Any thoughts on how to get round this much appreciated!
     
  2. Erel

    Erel Administrator Staff Member Licensed User

    Try to run /bin/sh and pass all other parameters as a single parameter.

    Worth trying it without sudo first.
     
  3. paddy12309

    paddy12309 Member

    Tried that with no success, its fine with the command until there's a '|' in there then it doesn't recognise it?
     
  4. Erel

    Erel Administrator Staff Member Licensed User

    Where is the updated code?
     
  5. paddy12309

    paddy12309 Member

    Sorry, ended up using a work around, as i could retrieve all running services fine i did that put them into a list and then went through the list to check it was running!
     
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice