Dear all, I want a java program which can connect to a remote host that runs on linux os and able to start and stop any application from that remote host. Is it possible to do this task with a java program, with or without any service wrapper!
-
3Maybe what you're looking for is an SSH library for java: stackoverflow.com/questions/995944/ssh-library-for-javaMarcoS– MarcoS2012-07-06 10:21:10 +00:00Commented Jul 6, 2012 at 10:21
-
stackoverflow.com/questions/4680448/java-ssh-client This might have some information which could help.David K– David K2012-07-06 10:23:02 +00:00Commented Jul 6, 2012 at 10:23
Add a comment
|
1 Answer
Check Ant SSHEXEC task.
Looks like there's no AntBuilder implementation in Java. Groovy is the ideal tool for these kind of tasks. You can write a Groovy and access it just like any other class in Java. If you are using NetBeans, then Groovy and Java can co-exist in the same package.
def String execute(def cmd, def host, def uname, def pwd)throws Exception {
def ant = new AntBuilder()
ant.sshexec(host : host,
username : uname,
password : pwd,
command : "ls -l,
trust : "true",
outputproperty : "result")
return ant.project.properties."result"
}