I am looking for libraries that I can use to send Unix commands from my Java code. I have already tried Expect4J and Gaynmed, but could not find good documentation with them. My requirements include:
- Running multiple commands.
- Capture output for previous command.
- Take some action/Run different command based on output of last command.
Any pointers will be appreciated.
Looking at the names of the libraries you mentioned, it seems like you want to run the commands on a remote server using ssh.
Check out http://code.google.com/p/sshxcute/
Code is pretty easy
Getting the output is easy too. Just check the link I provided.