Reputation: 1043
Wondering if anyone has a simple solution to doing a reboot of a linux box from a C# windows app. I can do the reboot using ssh, but really did not want to include the SSH lib files from Tamir Is there something else I could do besides bring in the full SSH lib for a simple reboot?
Here is how I do the reboot using Sharpssh from Tamir..
SshExec exec = new SshExec("192.168.1.1", "root", "password");
exec.RunCommand("/sbin/shutdown -r");
exec.Close();
Upvotes: 1
Views: 571
Reputation: 29963
Are you running Apache/PHP on the box? If so, a horribly insecure way may be to setup a PHP page to initiate the reboot. (You could attempt to add some security by requiring a login / obscure string supplied as a post variable, etc) You can then just use a WebRequest to call the page in question to initiate the reboot.
Please don't ask me about the security specifics of allowing a PHP page to call out to a system command with the required permissions - it has been far too long since I worked on Linux / PHP.
Upvotes: 1
Reputation: 6653
you could send a Remote Procedure Call.
http://www.cs.cf.ac.uk/Dave/C/node33.html
Upvotes: 1