Does the linux HS script support running bash scripts? I haven't tried the linux release yet, and haven't seen anything on the boards about it.
Announcement
Collapse
No announcement yet.
Linux HS: bash script support?
Collapse
X
-
Does not seem to work
It does not seem to work. The only way I could try is to create an event to start a program. You can select a program on the local filesystem, but I get this error when running this event.
Error Event system events New Event failed to launch \usr\bin\uptime as the file could not be found.
-
perl script on Linux
Following the HS3 documentation, Perl scripts run on Linux (and on Windows too). I have developed several perl scripts working on HS2 but for the moment, I don't find how to run them on HS3 Linux. However, they run on HS3 Windows.
I don't think that other scripting languages (e.g. Linux command in a bash file) run on Linux except if you run them as a executable program.
Comment
-
Linux HS: bash script support?
I just tried to run the restart.sh from an event just like Zigmund explains in post 3. Although the event shows the path with the "/" folder delimiters for Linux, the error seems to suggest that it's using the "\" delimiter for Windows when it tries to run and therefore cannot find the intended file.
Anyone from HST: Is this a known problem; needs a bug to be submitted, or just not supposed to be used the way that we are trying to use it?
Thanks Jamescheeryfool
Comment
-
fixed: hs3 script to run bash scripts on linux host
I managed to create a small script to run linux (bash) commands for homeseer on linux hosts. here it is:
Code:imports System.Diagnostics Sub Main(parm as object) Dim psi As New ProcessStartInfo() psi.FileName = "/bin/bash" psi.Arguments = "-c ""uname -a""" psi.RedirectStandardOutput = True psi.RedirectStandardError = True psi.CreateNoWindow = False psi.WindowStyle = ProcessWindowStyle.Hidden psi.UseShellExecute = False Dim process As Process = Process.Start(psi) Dim processoutput As String = process.StandardOutput.ReadToEnd() process.WaitForExit() hs.writelog("Output", processoutput) End Sub
Comment
-
I have an alternate and faster method of executing bash scripts on Linux using HomeSeers speak.sh.
I simply added the code:
Code:# Execute bash command case $1 in bash*) command=$(echo "$1" | sed -e 's/\<bash\>//g' | sed -e 's/^ *//') eval $command esac
This avoids the delay involved in executing using a vb script as the first time its run after each reboot can result in up to a 6 second delay on my system. Using this method I have seen no visible delay at all even after restart.
Obviously customise for your system as needed.
Comment
-
Very nice cytec!- Pete
Auto matorHomeseer 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 11X10, UPB, Zigbee, ZWave and Wifi MQTT automation-Tasmota-Espurna. OmniPro 2, Russound zoned audio, Alexa, Cheaper RFID, W800 and Home Assistant
Comment
-
Thanks for the info on this guys. I am using HS3 on Ubuntu, migrating from Vera where I used curl to POST to a Raspberry Pi running a relay board and Webiopi. This allows me to setup a low end amp and use the relay board to turn on/off rooms.
I set the executable to /usr/bin/curl and the variable to -X POST http://192.168.1.19:8000/GPIO/2/value/0 if anyone else was trying to do similiar and can't get urlaction to work.
JG
Comment
-
Originally posted by zigmund View PostI managed to create a small script to run linux (bash) commands for homeseer on linux hosts. here it is:
Code:imports System.Diagnostics Sub Main(parm as object) Dim psi As New ProcessStartInfo() psi.FileName = "/bin/bash" psi.Arguments = "-c ""uname -a""" psi.RedirectStandardOutput = True psi.RedirectStandardError = True psi.CreateNoWindow = False psi.WindowStyle = ProcessWindowStyle.Hidden psi.UseShellExecute = False Dim process As Process = Process.Start(psi) Dim processoutput As String = process.StandardOutput.ReadToEnd() process.WaitForExit() hs.writelog("Output", processoutput) End Sub
hey.
i am using your script for a long time to be able to run from hstouch bash scripts.
i have a small problem, i would like to pass parameters to the command.
this works
psi.Arguments = "-c ""/scripts/play_80.sh 192.168.1.1"""
this doesn't:
psi.Arguments = "-c ""/scripts/(parm(0).sh (parm(01))"""
i am guessing that it doesn't pass the parameters to the command line.
is there a way to change the line so it will use it?
thanks
Comment
-
maybe this will work
this will work: passing parm to the bash script command
use a comma to split the parameters. e.g. play80,192.168.1.2
Code:Sub Main(parm as object) Dim param1 As String = Split(parm,",")(0).ToString Dim param2 As String = Split(parm,",")(1).ToString .... Psi.Arguments As String = "-c " & " ""/scripts/" & param1 & ".sh " & param2 & " "" " .... End Sub
Comment
-
Thanks for your help.
the script looks like this now:
imports System.Diagnostics
Sub Main(parm as object)
Dim psi As New ProcessStartInfo()
Dim param1 As String = Split(parm,",")(0).ToString
Dim param2 As String = Split(parm,",")(1).ToString
psi.FileName = "/bin/bash"
'psi.Arguments = "-c ""/var/local/HomeSeer/scripts/media/70.sh 53"""
Psi.Arguments As String = "-c " & " ""/var/local/HomeSeer/scripts/media/" & param2 & ".sh " & param1 & " "" "
psi.RedirectStandardOutput = True
psi.RedirectStandardError = True
psi.CreateNoWindow = False
psi.WindowStyle = ProcessWindowStyle.Hidden
psi.UseShellExecute = False
Dim process As Process = Process.Start(psi)
Dim processoutput As String = process.StandardOutput.ReadToEnd()
process.WaitForExit()
hs.writelog("Output", processoutput)
End Sub
~
i can verify that parm(0) got the value 80
and parm(01) got the value 53
so the command should have looked like this:
Psi.Arguments As String = "-c " & " ""/var/local/HomeSeer/scripts/media/80.sh 53""" (which works when inserted directly into the command)
but now i get this in the log:
Mar-23 11:08:49 Error Compiling script play_media.vb: 'End Namespace' must be preceded by a matching 'Namespace'.
Mar-23 11:08:49 Error Compiling script play_media.vb: Identifier expected.
Mar-23 11:08:49 Error Compiling script play_media.vb: Identifier expected.
Mar-23 11:08:49 Error Compiling script play_media.vb: Identifier expected.
Mar-23 11:08:49 Error Compiling script play_media.vb: Identifier expected.
Mar-23 11:08:49 Error Compiling script play_media.vb: Identifier expected.
Mar-23 11:08:49 Error Compiling script play_media.vb: Identifier expected.
Mar-23 11:08:49 Error Compiling script play_media.vb: Identifier expected.
Mar-23 11:08:49 Error Compiling script play_media.vb: Identifier expected.
Mar-23 11:08:49 Error Compiling script play_media.vb: Identifier expected.
Mar-23 11:08:49 Error Compiling script play_media.vb: Identifier expected.
Mar-23 11:08:49 Error Compiling script play_media.vb: Expected 'End'.
Mar-23 11:08:49 Error Compiling script play_media.vb: Expected 'End'.
Mar-23 11:08:49 Error Compiling script play_media.vb: End of statement expected.Last edited by ez1976; March 23, 2016, 02:03 PM.
Comment
-
Excellent description of how to use shell scripts in Homeseer. Buuut I seem to be doing something wrong..
My configuration looks like what I have added as screenshots, but I can get the command to execute successfully if I run the script by itself, but when run through Homeseer as an event it doesn't work. Or nothing happens would be more correctly. Have I configured it wrong?
Comment
Comment