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!

2

1 Answer 1

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"
    }
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.