0

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!

  • 3
    Maybe what you're looking for is an SSH library for java: http://stackoverflow.com/questions/995944/ssh-library-for-java – MarcoS Jul 06 '12 at 10:21
  • http://stackoverflow.com/questions/4680448/java-ssh-client This might have some information which could help. – David K Jul 06 '12 at 10:23

1 Answers1

0

Check Ant SSHEXEC task.

link...

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"
    }
Sree
  • 746
  • 6
  • 21