Announcement

Collapse
No announcement yet.

Run Linux Command From Event

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Run Linux Command From Event

    I am trying to run a Linux command from my HS3 box to start/stop a service on a windows machine. I can SSH into the HS3 box and successfully run this:

    Code:
    sudo net rpc -I ADDRESS -U USERNAME%PASSWORD service {stop|start} SVCNAME
    I can not figure out how to run this from an event. Any help would be appreciated.

    Thanks,

    Jim

    #2
    Have a look here....

    Linux HS: bash script support?

    - Pete

    Auto mator
    Homeseer 3 Pro - 3.0.0.548 (Linux) - Ubuntu 18.04/W7e 64 bit Intel Haswell CPU 16Gb
    Homeseer Zee2 (Lite) - 3.0.0.548 (Linux) - Ubuntu 18.04/W7e - CherryTrail x5-Z8350 BeeLink 4Gb BT3 Pro
    HS4 Lite - Ubuntu 22.04 / Lenovo Tiny M900 / 32Gb Ram

    HS4 Pro - V4.1.18.1 - Ubuntu 22.04 / Lenova Tiny M900 / 32Gb Ram
    HSTouch on Intel tabletop tablets (Jogglers) - Asus AIO - Windows 11

    X10, UPB, Zigbee, ZWave and Wifi MQTT automation-Tasmota-Espurna. OmniPro 2, Russound zoned audio, Alexa, Cheaper RFID, W800 and Home Assistant

    Comment


      #3
      Originally posted by Pete View Post
      Have a look here....

      Linux HS: bash script support?
      Thanks Pete. I went to that thread which references another thread. Doesn't make sense to me.

      Can anyone give me and example using the command I want to execute. I would rather put everything in a script, not execute an immediate script command.

      Thanks,

      Jim

      Comment


        #4
        Jim,

        Cytec explained it the best using the a script called bash:

        # Execute bash command
        case $1 in bash*)
        command=$(echo "$1" | sed -e 's/\<bash\>//g' | sed -e 's/^ *//')
        eval $command
        esac

        This attachment shows a line command:

        Click image for larger version  Name:	fetch?id=1180040.jpg Views:	0 Size:	46.0 KB ID:	1337517
        This one shows a executible bash script.

        IE: you run the script bash following the the bash script called clean.sh

        So you install a script called bash in your script directory and another one called startservice.sh or stopservice.sh

        Click image for larger version  Name:	fetch?id=1180041.jpg Views:	0 Size:	27.9 KB ID:	1337518
        - Pete

        Auto mator
        Homeseer 3 Pro - 3.0.0.548 (Linux) - Ubuntu 18.04/W7e 64 bit Intel Haswell CPU 16Gb
        Homeseer Zee2 (Lite) - 3.0.0.548 (Linux) - Ubuntu 18.04/W7e - CherryTrail x5-Z8350 BeeLink 4Gb BT3 Pro
        HS4 Lite - Ubuntu 22.04 / Lenovo Tiny M900 / 32Gb Ram

        HS4 Pro - V4.1.18.1 - Ubuntu 22.04 / Lenova Tiny M900 / 32Gb Ram
        HSTouch on Intel tabletop tablets (Jogglers) - Asus AIO - Windows 11

        X10, UPB, Zigbee, ZWave and Wifi MQTT automation-Tasmota-Espurna. OmniPro 2, Russound zoned audio, Alexa, Cheaper RFID, W800 and Home Assistant

        Comment


          #5
          I think you want "Run Another Program or Process" action.

          Use the Edit button to select the program to run, then enter all the command line arguments in the 'command parameters' field.

          In the command you posted above, did you mean 'ssh' rather than 'sudo' ? sudo doesn't make much sense in that context, as 'net' isn't a Linux command.

          You don't actually need to sudo, since HS3 is running as root already.
          Attached Files

          Comment

          Working...
          X