开发者

How to connect to a remote unix box from java and run unix script in it?

开发者 https://www.devze.com 2023-04-08 11:05 出处:网络
I need help in writing java code that can connect to a remote UNIX box, and run a script on that box.

I need help in writing java code that can connect to a remote UNIX box, and run a script on that box. I have scoured the internet, but I have been unable to find proper documentation on how this can be accomplished.

Where is the b开发者_JAVA百科est place to start reading about this ? What all should I know ?

Any help is appreciated. Thanks.


ssh is probably the best protocol to use for that sort of thing. It's more secure than telnet and can be set to up to use authentication keys so your code won't need to know (or ask the user) for the password to the remote box.

Java Secure Channel (JSch) is a popular pure Java implementation of the ssh protocol.


You can use telnet and/or ssh to connect to the box. Then you can send your command, as you would do it in a terminal. Look out for a telnet/ssh implementation for java with good documentation. Telnet should be simpler, but there is no encryption. Apache has a telnet implementation: http://commons.apache.org/net/

regards Andreas


You could use Runtime.exec(java.lang.String)

0

精彩评论

暂无评论...
验证码 换一张
取 消