Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
The moose likes Sockets and Internet Protocols and the fly likes How to execute linux script remotely from java program on windows Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Sockets and Internet Protocols
Bookmark "How to execute linux script remotely from java program on windows" Watch "How to execute linux script remotely from java program on windows" New topic
Author

How to execute linux script remotely from java program on windows

Srinivas Kumar
Ranch Hand

Joined: Jul 14, 2005
Posts: 52
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
Marshal

Joined: Mar 22, 2005
Posts: 41600
    
  55
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.


Ping & DNS - my free Android networking tools app
Nitesh Kant
Bartender

Joined: Feb 25, 2007
Posts: 1638

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


apigee, a better way to API!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to execute linux script remotely from java program on windows