jwiseman
(Mr. Wiseman (OH 4.3.0 Snapshot on Pi4))
1
I’m seeing data coming back from a different BASH script which means I believe OH may be using the same BASH session. Variables used are different for every BASH script I call also.
var String results7 = executeCommandLine(Duration.ofSeconds(5), "/bin/bash", "/etc/openhab/scripts/NWSAlerts.sh")
What is the proper way to close a BASH script after execution? I’m doing this below:
I’m getting output from speedtest on the ouraring output from the logging, which makes me believe that the speedtest BASH session isn’t closing all the way.
The speedtest.sh is using python within the script, not sure that matters.
When I run them manually at the prompt, everything works perfectly.
Here’s what I’m talking about, speedtest stuff first then ouraring next. The try blocks have different variables also.
2025-03-03 11:20:51.234 [ERROR] [org.openhab.core.model.script.OURA ] - Oura Readiness Score - Error while processing JSON response via CURL. Exception is For input string: "% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0
100 400 100 400 0 0 1269 0 --:--:-- --:--:-- --:--:-- 1269
{"data":[{"id":"c4e592b0-fd83-44b9-a91c-825f153adbec","contributors":{"activity_balance":90,"body_temperature":100,"hrv_balance":null,"previous_day_activity":92,"previous_night":98,"recovery_index":61,"resting_heart_rate":93,"sleep_balance":88},"day":"2025-03-03","score":88,"temperature_deviation":-0.07,"temperature_trend_deviation":0.03,"timestamp":"2025-03-03T00:00:00+00:00"}],"next_token":null}"
If the shell scripts were not exiting, you’d be getting timeout errors from OH after five seconds (given your call in the OP). I don’t think you get any output from the script if it times out like that either.
Since you are getting the output and you are not getting timeout errors ther scripts are exiting.
This error indicates that it’s trying to parse the Dload Upload … part of the output as JSON. I’m assuming that’s from your Python script.
Obviously that’s not going to work. Nothing until you get the {“data”:… part is JSON so none of that first part is parsable as such. And OH is showing the raw output of the Python script aparently.
I don’t know the scripts. I don’t know the rules.
But with the information provided I see no indication that the scripts are not exiting. What I see is your scripts are returning stuff you may not expect perhaps and/or your scripts are failing to complete for reasons.
I can’t explain why it works from the command line except that it’s likely running as a different user when OH runs it than you run it as from the command line.
jwiseman
(Mr. Wiseman (OH 4.3.0 Snapshot on Pi4))
6
This was a rookie move, when I run the scripts manually the CURL doesn’t show the progress information. When I run them via OH executeCommandLine its outputting the progress information which looks like the speedtest runs.
Adding the -s (silent) on the CURL switch fixed everything.