Calling Shell command

Hi guy,
I’ve been trying to run a Shell command from HomeGenie for several days. I assigned the permissions and did everything.
Please, there is someone who has an easy method to execute a shell command from Homegenie (C + or Python or Java doesn’t matter)?

N.B. From the Shell, it is sufficient for me to type /home/pi/share/ and the program runs. (The bash file is used to run a python3 script).
I thank in advance those who will be able to give an answer.

Calling shell commands isn’t that difficult.
I posted a few programs which call simple pi shell commands to display pi stats on the X10 forum here
Viewing the code should give you the jist.

1 Like

Obviously I tried with the following method found in other posts, but despite the many attempts (file permissions, bash program, python program, execute=true/false etc…) I am not able to execute the shell command from a Home Genie program.

var proc = new System.Diagnostics.Process {
StartInfo = new System.Diagnostics.ProcessStartInfo {
FileName = “sh”,
Arguments = “/home/pi/share/”,
UseShellExecute = false,
RedirectStandardOutput = true,
CreateNoWindow = true
while (!proc.StandardOutput.EndOfStream) {
string line = proc.StandardOutput.ReadLine();
Program.Notify(“SHELL COMMAND”, line);

Your issue is the file name I think

Hi Tuicemen,
I am very grateful for your response.
I think you are right about the name of the file, but the one I mentioned above is just one of the many tests done with bash, python etc … following various suggestions (Changing filename, arguments, options true/false etc … .).
Please, to which of your link programs are you referring to? Have you used other methods?

I’m away on a hunt trip using my phone so not able to dig into my code from here so things are from memory. If I remember the file name is bin/bash the example i posted includes several calls and puts all info in one display program. They are shell calls to the pi OS so path would be different for your script but thats all

Thanks for your suggestions. And I’m sorry if I still bother you during your hunt.

I tried using the file name bin / bash… With this change an error appears during the execution of the program warns that it is not possible to find the file.
Perhaps it is not correct to insert the file name together with the path?

Please, do you know what the native directory is? (I could do a test by copying the file to the native directory, and put as arguments only the file name without path. (Arguments = “")

ApplicationName=‘bin/bash’, CommandLine=’/home/pi/share/’, CurrentDirectory=’’, Native error= Cannot find the specified file

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

@roberto1979 here’s another link that may be of interest to you from the old HomeGenie forum

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

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

@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 from the shell, I get an error. So, i can lunch the program simple with the command “”, but not with the command “sudo”.

Did you set the privileges and permissions correctly when using the chmod command to create your executable script. Type ls -l 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

1 Like

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

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

Could you post your script