I am working on a customized system that is in the middle of migrating from X10 to Insteon, and I REALLY like the OpenRemote interface... I am looking for documentation on how to have to the application execute a local shell command - most notably to use the X10 SDK command line executable to send the appropriate commands to the controller. There is a "ghetto hack" where I can install Apache and execute commands through HTTP, but I would like to reduce the system overhead, and simply execute a command at the system shell level.
Is this possible? If it is, then that opens up a TON of possibilities for this platform - and is something I am seriously using for running remote support scripts in the data centers I support, etc.
Any help is greatly appreciated!
Thanks,
Bob
Comments (17)
Dec 16
Marcus Redeker says:
In general it is possible to start shell commands from within Java. You could e...In general it is possible to start shell commands from within Java.
You could easily create a new protocol that takes the path to the executable or shell scripts and that will be started when pushing a button.
Dec 16
Bob P says:
If you could provide some pointers, I would appreciate it - I am NOT a programme...If you could provide some pointers, I would appreciate it - I am NOT a programmer, but I am pretty sure I could hack something to make it work. I see a LOT of potential uses for this type of functionality - I am working through a few designs at the moment to use this capability to run HVAC controls, and perform system commands (such as remotely rebooting a server, restarting a service, etc using PSEXEC).
To anyone else in the community: If you also see a need for this, lets work together on this. What I envision is a simple interface that allows you to define an executable (must be able to be located in a directory that contains spaces) and command line switches (such as "psexec -i -d -s c:\windows\regedit.exe") and run in the context of the user account running OpenRemote (should make it a bit easier).
Thanks a ton!
Bob
Dec 16
Marcus Redeker says:
For this to work in Java you need to create a String array with the command as f...For this to work in Java you need to create a String array with the command as first entry and the params follow.
In your example the String array could either look like this:
{"psexec", "-i", "-d", "-s c:\windows\regedit.exe"}
or like this
{"psexec", "-i", "-d", "-s", "c:\windows\regedit.exe"}
And this is one problem we might have.
How would you specify in one or 2 textfields (within our designer webapp) what is the command and what are parameters and parameter values?
Dec 19
Bob P says:
Well, it could be just one text field for all I care (I don't mean for that to s...Well, it could be just one text field for all I care (I don't mean for that to sound flip - it really doesn't matter to me...) but in the past this was needed because of the need for " in different places - it tended to jam different applications up.
Since I am NOT a programmer, is there a protocol plugin that I can use, just change the commands executed, instead of recreating the wheel?
Thanks,
Bob
Dec 22
Marcus Redeker says:
Ok, I just implemented support for a new "shellexe" protocol. This protocol can ...Ok, I just implemented support for a new "shellexe" protocol. This protocol can be configured with the full path to the executable and one extra parameter. If you want to start something which needs more sophisticated parameter, you can just create a batch file and start from there.
The protocol is only available in my developer branch "Controller_EP_SNAP_20111102_NewProtocols" but Juha should be able to integrate this into the upcoming 2.0 release.
Dec 23
remylpat says:
Hi markus, does your Protocol works under linux too. I you need tester my openr...Hi markus,
does your Protocol works under linux too.
I you need tester my openremote controller is running on a SYNOLOGY NAS and I am really interested on your controller.
many Thanks for your help
Dec 23
Marcus Redeker says:
I am using general Java commands todo this. This should work on all platforms.I am using general Java commands todo this. This should work on all platforms.
Dec 25
Bob P says:
Sorry for the delay in response - holidays are brutal! Thanks a TON for this! ...Sorry for the delay in response - holidays are brutal!
Thanks a TON for this! I will be sure to post up what I am doing to help the next person!
Jan 03
remylpat says:
Hi all, I am a little bit lost. Can we or not execute shell command ? How to do...Hi all,
I am a little bit lost.
Can we or not execute shell command ?
How to do it ?
Can we test ?
Many thanks
Jan 03
Marcus Redeker says:
I implemented to protocol but it's not in the official download of the controlle...I implemented to protocol but it's not in the official download of the controller.
I just commited into the 20111129 snapshot which is in Juha's workspace folder in SVN.
You can download the source from there and test if you would like.
The needed xml fragment for the controller.xml looks like this:
<command id="87" protocol="shellexe"> <property name="commandParams" value="..." /> <property name="commandPath" value="..." /> </command>Jan 03
remylpat says:
Sorry for that noob question but how to download the source code and where run/t...Sorry for that noob question but how to download the source code and where run/test it on my system ?
Jan 03
Marcus Redeker says:
I just created a snapshot of the latest controller to download. You can try this...I just created a snapshot of the latest controller to download.
You can try this version: www.redeker-consulting.de/openremote/OpenRemote-Controller-2.0.0_SNAPSHOT_20120103.zip
The "Shell Execution" protocol was also added to the online designer, so you don't have to edit any xml just go online and create a "shellexe" command and link to a button.
Jan 09
remylpat says:
Hi markus, Thanks for the linkand the snapshot. I tried to install it on my syn...Hi markus,
Thanks for the linkand the snapshot.
I tried to install it on my synology but failed.
The designer is up2date and I was thinking the controller too (I overwrited the old files with the new ones, changed the Port to the one I used, but each time I try to uplad my new design to the con,troller it failed. I have also other java error when running).
Is there a release date for this new version ?
Regards
Jan 09
Marcus Redeker says:
I don't have a release date. What errors do you see?I don't have a release date.
What errors do you see?
Jan 10
remylpat says:
I will try re-install it tonight and update the thread with msg errorsI will try re-install it tonight and update the thread with msg errors
Jan 12
remylpat says:
Here is one of the messages I had : org.openremote.controller.protocol.shellexe...Here is one of the messages I had :
org.openremote.controller.protocol.shellexe.ShellExeCommand.send(60) | Could not execute shell command: /bin/sh /volume1/homes/admin/GoogleMeteo.sh
java.io.IOException: Cannot run program "/bin/sh /volume1/homes/admin/GoogleMeteo.sh ": java.io.IOException: error=2, No such file or directory
Jan 12
Marcus Redeker says:
How did you configure that in the designer? "/bin/sh" as full path to executable...How did you configure that in the designer?
"/bin/sh" as full path to executable
and
"/volume1/homes/admin/GoogleMeteo.sh" as additional command param?
If not, then that would be the problem.
Other way would be that "/bin/sh" is the first line in "GoogleMeteo.sh"
like this "#!/bin/sh"
and then you just put the full path to "GoogleMeteo.sh" as path to executable and you have to chmod +x the file.