Calling Shell command

File name line should be “/bin/bash”,
Path line I believe is c sudo path file name
If I could access things i wouldnt have to rely on my memory which isn’t as sharp as it use to be.
Down loading the program I posted the link to and installing it would be the easiest wat to see things in action.
Native or home pi directory i believe is pi/home but I most likely am wrong.

1 Like

@roberto1979 if you check the old HomeGenie forum most of that work has already been done. Here’s a link to calling a shell script within HG http://old.homegenie.club:8080/www.homegenie.it/forum/index6f97.html?topic=1399.0

@roberto1979 here’s another link that may be of interest to you from the old HomeGenie forum http://old.homegenie.club:8080/www.homegenie.it/forum/indexed45-2.html?topic=352.msg1999#msg1999

A lot of what you are probably trying to achieve has probably already been done in the old forum. That’s where most users get their tips from. A google search should include the words old HomeGenie forum which allows you to search the old HomeGenie forum. You should find most of what you are looking for that way.

Hi Pretediscrete,
Thank you for your answer.
As I said a few posts above, unfortunately I have already tried all these methods of your links present in the old homegenie forum.
I have also tried to change file permissions, and much more, but it doesn’t work.
Please, maybe are you able to send a shell command with other methods (although less secure), exactly as if you were typing via ssh? (For example using python or Java?)

Have you tried the following. This should sort out your PATH issues https://stackoverflow.com/questions/8779951/how-do-i-run-a-shell-script-without-using-sh-or-bash-commands

In order to rule out privileges issues from within HG have you tried using sudo /home/pi/share/sendrf.sh

@roberto1979 your issue may e you haven’t made your sh file executable. If it isn’t ececutable it wont run

I think he’s already stated that he has it running from the command line in the OP.

Thanks for your answers. Unfortunately I have already tried all these things. I made the executable file, granted privileges to the file, to the directory, and much more…
This is why I was wondering if perhaps you are able to send commands in other ways, for example via phyton script.

P.S.I use this bash file, to launch an RF command using a Phyton script of rpi-rf. The strange thing, of which I don’t know the reason, (but maybe could help you to understand the problem), is that if I add sudo to the sendrf.sh from the shell, I get an error. So, i can lunch the program simple with the command “sendrf.sh”, but not with the command “sudo sendrf.sh”.

Did you set the privileges and permissions correctly when using the chmod command to create your executable script. Type ls -l sendrf.sh at the command line and paste the output

Did you add a shebang as the first line of your script like this

#! /bin/bash

and set the executable rights like this

sudo chmod +x sendrf.sh

1 Like

Currently the file permissions are root root … I had also tried with Pi … all user…

[email protected]:/ $ ls -l sendrf.sh
-rwxr-xr-x 1 root root 63 nov 10 02:01 sendrf.sh

Could you post your sendrf.sh script

#! /bin/bash
cd /
/usr/bin/python3 /usr/local/bin/homegenie/send.py 000000

What version of Python are you using. If I recall HG only supported Python 2.x yet you are using a Python 3.x script

What does python —version report

Homegenie uses python2 … But by running the script from Shell I use python3 and all work fine. (rpi-rf call a python3).
Recalling the file from Shell, it should not affect the Pyhthon version of HG, is that correct? (In fact from Shell the Bash file is executed correctly).

and… The system default Python version is 2.7… but the script calls python3 for the execution of the preogram.

Please, also consider that the script works without any problems even from the raspbian crontab…For this reason I was wondering if perhaps you are able to call the script from homegenie via other ways…

What exactly is the purpose of your Python program. What does it do and why did you create it in Python 3.

Mixing Python versions is not something I’ve ever needed to do but this might give you an insight into how it can be done. https://stackoverflow.com/questions/27863832/calling-python-2-script-from-python-3

I’m assuming you created your bin bash script correctly, made it executable properly and had the absolute path correctly defined.

As you say it runs fine from the cli so I imagine your problem is either path related or there’s a problem between Python versions.