Announcement

Collapse
No announcement yet.

executing bash script

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

  • reidfo
    replied
    Originally posted by dssabo View Post
    I'm pretty certain it did have both of those.
    Is there any disadvantage to what I ended up doing?

    Thanks again
    Probably not. It just requires you to explicitly execute the shell. This way the script name is the first command line parameter, then subsequent parameters should be passed to the script. As long as your parameters are working within your script there's no real downside.

    I'm curious though as to why you're not able to run the script directly. Can you provide a directory listing of the directory where the script is stored? For example, I put mine in /usr/local/HomeSeer/Scripts, so the command is:
    Code:
    ls -l /usr/local/HomeSeer/Scripts

    Leave a comment:


  • dssabo
    replied
    I'm pretty certain it did have both of those.
    Is there any disadvantage to what I ended up doing?

    Thanks again

    Leave a comment:


  • reidfo
    replied
    Originally posted by dssabo View Post
    I was able to get this to work by making the program I want to run simply /bin/bash and then I put the full path to my .sh script as an argument.
    This would probably indicate that the script doesn't have execute permissions (chmod 755) on it, and/or does not have this as the first line of the script:
    Code:
    #!/bin/bash

    Leave a comment:


  • dssabo
    replied
    I was able to get this to work by making the program I want to run simply /bin/bash and then I put the full path to my .sh script as an argument.

    Leave a comment:


  • dssabo
    replied
    Thank you for the reply. That gives me hope, but among my various attempts, that was one that I had tried with no luck. I executed your chmod command to make sure that isn't the issue. Still no luck. I trigger the Event using the "Run the event actions" button. I look in the log and see that the event was triggered and that there is no error message.

    However, the action I expect (a push notification to my phone) doesn't happen. It works perfectly when I execute the same file from within linux.

    Incidentally, I asked someone from support about this and got this response:

    "Looks like HomeSeer cannot cannot trigger a bash script in an event but you can trigger a vb script that then triggers the bash script."

    They then provided me with the VB script. But that sure seems like the hard way to do it.

    If you have this working, it would seem that their statement isn't true.

    Could it have something to do with the user that is running it? I log into linux as the user 'homeseer'. I would imagine that Events are triggered using that user as well, but I guess I don't know.

    Leave a comment:


  • reidfo
    replied
    You can run it as you would any other script. I have a test script that I run from an event. Give the full path to the script. You can optionally pass parameters to it as well as I did in the example below. Also make sure you make the script executable with 'chmod 755 <filename>.sh'
    Attached Files

    Leave a comment:


  • dssabo
    started a topic executing bash script

    executing bash script

    Elsewhere on this forum, I found a post showing the code in various scripting languages for sending a push notification using Pushover. One of the methods listed was "linux" and it used the curl command.

    With the required changes, I put the command into a file with "#!/bin/bash" as the first line and made it executable. When I execute this from within linux, I have success generating a push to my device.

    What I thought would be the easy part has stumped me. I haven't been able to determine how I can set up a HS Event using the web interface to execute this "bash script".

    Can anyone help?
    Last edited by dssabo; February 17, 2016, 10:57 AM.
Working...
X