Using putty to shutdown linux in c# -
i encountered problems during writing application shutdown/restart linux windows in c#.
i'm trying use putty task, wrong.
process p = new process(); processstartinfo info = new processstartinfo(); info.filename = "putty.exe"; info.redirectstandardinput = true; info.useshellexecute = false; info.arguments = @"root@192.168.0.25 -pw 1234qwer "; p.startinfo = info; p.start(); p.standardinput.writeline("shutdown -h "); p.standardinput.writeline("exit"); string output = p.standardoutput.readtoend(); p.waitforexit(); console.writeline(output);
above i've pasted code i've used achieve goal. fine till have write more in putty command line, in case standardinput not way , didn't find other way this.
i tried use plink.exe in same way didn't solve problems - in fact plink not show up.
any ideas or tips how solve problem great.
try ssh.net
using (var client = new sshclient("hostnameorip", "username", "password")) { client.connect(); client.runcommand("shutdown -h now;systemctl poweroff"); client.disconnect(); }
Comments
Post a Comment