Hi all , I need to remotely shutdown a linux machine from a windows machine through java program

I need to remotely shutdown a linux machine from a windows server machine through java program . Is there any direct command to do that.

Answers


from the java program connect to the linux machine via ssh

and run shutdown command

via sshj:

SSHClient ssh = new SSHClient();

ssh.loadKnownHosts();
ssh.connect("your-server");
ssh.authPublickey("userId");

//START SESSION
Session session = ssh.startSession();
//SEND THE COMMAND
Command cmd = session.exec("shutdown");
//GET THE OUTPUT OF COMMAND
cmd.getOutputAsString();
//CLOSE SESSION
session.close();
ssh.disconnect();

Need Your Help

Linq - Retrieve value from a linked linked table

linq

I have the following model and relationship:

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.