Kannan_g Posted March 23, 2015 Share Posted March 23, 2015 Hi,I need to SSH to a device in my home network to issue a command. Is there a driver that will allow me to execute / run a shell command? I've already tested the SSH command that I want to use from the C4 command line (after logging in with the 'secret' password) and it works. Just need to figure out how to use it programmatically from within C4.I tried the Chowmain Generic TCP driver but I think that only allows HTTP commands to be sent.Any help would be most appreciated. msgreenf 1 Quote Link to comment Share on other sites More sharing options...
AK1 Posted March 24, 2015 Share Posted March 24, 2015 Can you post the SSH command you need to issue? Quote Link to comment Share on other sites More sharing options...
Kannan_g Posted March 24, 2015 Author Share Posted March 24, 2015 Hi AK1, Here's the SSH command: ssh -i ~/.ssh/id_rsa username@IPaddress -t open "/path/appname" Thanks in advance! Quote Link to comment Share on other sites More sharing options...
AK1 Posted March 24, 2015 Share Posted March 24, 2015 Thanks, can you explain why it must be run from a C4 controller which is essentially just a Linux box. You could certainly run this programatically from the Linux side of things e.g. using a scheduled crontab entry. However, I would be leery of doing too much "vanilla" Linux work on a box like a C4 controller which has a highly specialized form of Linux. Could you run the command? Putty has a form of SSH command line capability, if I recall correctly from some time ago. Or run it from OS X on a Mac (BSD). Quote Link to comment Share on other sites More sharing options...
Kannan_g Posted March 24, 2015 Author Share Posted March 24, 2015 I need the command to run when I switch to a particular video source on C4. It's to basically fire-up an application on my home media server (Mac Mini). For certain reasons, I can't have the app running all the time. So I plan to start the app when I switch to that source, and quit the app (via ssh) when I turn off the room or switch to another source. I'm open to alternatives but can't think of one ... Quote Link to comment Share on other sites More sharing options...
AK1 Posted March 24, 2015 Share Posted March 24, 2015 Hmm, I can't think of a way to do this from C4 itself - although it wouldn't surprise me if tech support or development at Contol4 has an undocumented capability in this area. Could you use the TCP driver to send a TCP or HTTP message to your Mac which in turn executes the SSH? You'll of cpurse need a program or web server running on your Mac to receive the command and act accordingly. Quote Link to comment Share on other sites More sharing options...
Kannan_g Posted March 24, 2015 Author Share Posted March 24, 2015 Your suggestion could work if the CGI script can execute a shell command. I haven't touched Perl in years though ... Quote Link to comment Share on other sites More sharing options...
AK1 Posted March 24, 2015 Share Posted March 24, 2015 I would do it in a shell script - perhaps I am too old school Quote Link to comment Share on other sites More sharing options...
msgreenf Posted December 26, 2016 Share Posted December 26, 2016 Did you ever get this? I was thinking about trying to write an ssh driver Sent from my STV100-1 using Tapatalk Quote Link to comment Share on other sites More sharing options...
Kannan_g Posted December 27, 2016 Author Share Posted December 27, 2016 Unfortunately not. I run the scripts off a Mac mini that is my media server. I would be greatly interested in beta testing / purchasing your ssh driver if go ahead and write it. Quote Link to comment Share on other sites More sharing options...
msgreenf Posted December 27, 2016 Share Posted December 27, 2016 Unfortunately not. I run the scripts off a Mac mini that is my media server. I would be greatly interested in beta testing / purchasing your ssh driver if go ahead and write it. Can't do it right now. No way. Research was a dead end Sent from my Nexus 6P using Tapatalk Quote Link to comment Share on other sites More sharing options...
VegardK Posted July 8, 2018 Share Posted July 8, 2018 Any luck with this? I would want to send a ssh reboot command for a system from Control4. Quote Link to comment Share on other sites More sharing options...
zaphod Posted July 9, 2018 Share Posted July 9, 2018 I would suggest using a separate computer running Apache to accomplish this in conjunction with the Generic TCP driver. Have the generic TCP drive hit a URL that you create on a Linux web server, a Raspberry Pi will do for this. Have that execute the ssh command that you need when that URL gets hit. I do similar stuff today with my C4 system - I have it launch Python scripts to do various things, including allowing me to interface with my Tesla, like starting/stopping chargin, turnin on the clmiate system, etc. Quote Link to comment Share on other sites More sharing options...
walterlara Posted July 7, 2021 Share Posted July 7, 2021 Here is a PHP file I created to help in converting a tcp request to run ssh command on a computer or other device. <?php $connection = ssh2_connect($_GET['ip'], 22); ssh2_auth_password($connection, $_GET['user'], $_GET['pass']); $stream = ssh2_exec($connection, $_GET['cmd']); ?> I have it running on my Synology's Web Station app with SSH2 PHP extension enabled. Type the URL of the hosted file , for this example I'll use cmd.php as the filename and include example parameters for IP, USER, PASS, and the CMD. Ex: http://192.168.1.2/cmd.php?ip=192.168.1.3&user=username&pass=password&cmd=say hello this is a test Open a web browser (like chrome) and paste this in so you can test if the command worked properly and if it did. http://192.168.1.2/cmd.php?ip=192.168.1.3&user=username&pass=password&cmd=say%20hello%20this%20is%20a%20test copy this encoded url from chrome's address bar and put this in the TCP driver in control4. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.