Executing batch file on remote system using Java
How to execute a batch file located on Windows remote system? Batch fil开发者_C百科e should run on remote system.
Abhinav, For your problem I see RMI is the quickest possible solution
- Check out the basics from these links (1,2)
- Start the server from where you want to run the batch
- In the Remote object on the server side Use
Runtime.getRuntime().exec()
to run your batch. - From the client machine give call to this remote object and method.
Another approach is to use SSH like sshj. This only requires the remote system to have SSH installed and is more secure than RMI.
You can use Jsch and Expect4j for executing commands on remote machine(window/Linux). Further more, if your system allows, transfer the batch file on remote machine using some FTP utility like Apache Commons Net and then execute commands that executes the script.
精彩评论