• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to execute linux script remotely from java program on windows

 
Srinivas Kumar
Ranch Hand
Posts: 52
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I want to execute a linux script from my java program residing on a windows machine. Can anybody help me in this regard? I can use the other tools like telnet to connect to linux machine and execute scripts but I would like to do it from the java program without going through the tools.
Appreciate your suggestions
 
Ulf Dittmer
Rancher
Posts: 42968
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
A Java application can use Telnet programmatically through a library like Apache Commons Net. That would be one way.

Another would be to run a servlet (or some kind of server-side web component) on the Linux box that starts the script using ProcessBuilder or Runtime.exec. The Java app could then start it by accessing a particular URL.
 
Nitesh Kant
Bartender
Posts: 1638
IntelliJ IDE Java MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
J2ssh is an open source library that supports ssh2 protocol.
You can use this library to login to the unix box remotely and do what you want
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic