Search code examples
apache-commons-exec

series of commands using commons-exec


I am new to apache commons-exec.

Is there a way I can send a series of commands to a remote machine without authenticating each time?

would like to do this order:

ssh a@b
command1
command2

but apparently commons-exec needs this:

ssh a@b \n command1
ssh a@b \n command2

any idea?


Solution

  • Try

    ssh a@b "command1; command2"
    

    this is a common way to execute multiple command on a remote system via ssh from within a script. This should work for your case as well.