Sumit Jain
Sumit Jain

Reputation: 31

How to automate putty from java

Is there any way so that i can automate putty from java class including running,login and sending unix commands one by one to executeand.

I have a some specific command list that i wan't to execute on server for that i wan't to automate putty.

Upvotes: 3

Views: 12615

Answers (3)

Harry B
Harry B

Reputation: 1

The easiest way is to write a .bat file which will have your putty login details and then a text file which will have your commands. Then you could run that .bat file which will open putty and run all the commands you have in the list.

But, after doing all this my requirement has changed to having a independent GUI to manage my server, so I would agree with Ravn Anderson but that would take a lot of effort.

So it all depends what sort of application you need.

Upvotes: 0

You do not want to run putty as it expects a GUI environment which is not available when launched from Java.

You need a suitable ssh library which can handle the connection and send commands and received responses. This allow you to fully script it from inside java.

I have heard good things about jsch - http://www.jcraft.com/jsch/ - but have not used it myself.

Upvotes: 4

Persimmonium
Persimmonium

Reputation: 15789

maybe you could automate it at command line level, using expectj

Upvotes: 1

Related Questions