Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cant exec shell script #1390

Open
lybserv2 opened this issue Aug 11, 2023 · 4 comments
Open

cant exec shell script #1390

lybserv2 opened this issue Aug 11, 2023 · 4 comments
Labels

Comments

@lybserv2
Copy link

trying to run a shell script via execute command, i tried like everything and cant get it to work

i type in "/home/pi/ac_off.sh" in the execute command section.

ac_off.sh contains:
#!/bin/sh

/home/pi/.local/bin/midea-beautiful-air-cli set --ip 192.168.2.70 --token xxx --key xxx --running 0

It wont execute it, chmod +x is set, tried with root and pi user, tried with sh and /bin/sh in front of the command.. nothing. HaBridge shows no error, it says the command is executed successfully.
I got another device in habridge which controls my hyperion ambilight with "/home/pi/hyperion/build/bin/hyperion-remote --on" for example, this works flawlessly.

If i put the hyperion command in the shell script it doesnt work, too. So it has something to do with sh scripts itself?

Would be happy for a hint, cheers!

@bwssytems
Copy link
Owner

Unfortunately, you still need to preface the command with "sh" as there is no environment settings in the exec from the system. Try "sh /home/pi/ac_off.sh"

@v4mp1
Copy link

v4mp1 commented Sep 17, 2023

I had the same problem, did not matter if I executed it directly or as script or as systemctl service. Nothing worked.
The solution was my service wanted to run as user and not root.
But my ha-bridge was started as root and not user.

Check if midea-beautiful-air-cli has to be executed as user and if yoa ure running ha-bridge as root.
Both together does not work, at least in my example.

You can run ha-bridge as user if you set the port outside of the privileged port range (1-1023):

java -jar -Dserver.port=31337 ha-bridge-v5.4.1.jar
http://YourIP:31337

Edit:

Ok but with a port other than 80, Alexa could not find my ha-bridge devices.
Now I was in a dilemma, my commadn which I launch through the script only works as user but I can not launch ha-bridge as user.
The solution was to give java the rights to run it on port 80 as user:

sudo apt-get install libcap2-bin
sudo setcap cap_net_bind_service=+ep $(readlink -f java)
java -jar ha-bridge-v5.4.1.jar

Maybe this helps someone.
I just want to make it clear again, the script itself running within ha-brdige was not my problem.
The problem was the command in the script had to be run as user.

@lacojim
Copy link

lacojim commented Nov 11, 2023

Edit:

Ok but with a port other than 80, Alexa could not find my ha-bridge devices. Now I was in a dilemma, my commadn which I launch through the script only works as user but I can not launch ha-bridge as user. The solution was to give java the rights to run it on port 80 as user:

Maybe this helps someone. I just want to make it clear again, the script itself running within ha-brdige was not my problem. The problem was the command in the script had to be run as user.

I actually ran into both these issues a few weeks ago. I moved HA-Bridge to port 85 so I could free up 80 for something else. Wrong! Broke pretty much everything. Then I had set up a script to control an Onkyo receiver. Could not make it work at all until I changed the commands WITHIN the script to run as su -c "command" username

@arnieSkyNet
Copy link

I use they x-10 heyu software to operate lots of things, and if I assigned an operation that wasn't part of they heyu (like irclient from irtrans) into a heyu alias, I found it called any shell/script, avoiding the "sh" thing.

I presume heyu adds a shell.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

5 participants