开发者

How to run a shell script from a remote machine?

Again I am in a serious problem .. please help me out.

I have to change a date and time of a server which is linux based . But that server is a remote server . Means I have to make an application which will change the time of the server , but that application will run on separate server. I am developing my code in java so I have to implement it with a java program please help me out. and tell me how to solve this problem. If possible give me the code spec. If it is possible by doing ssh then please tell me how to create ssh using a java program. I am giving the scenario the java program sh开发者_如何学JAVAould run on machine A and i have to change the server date time of machine B.


Your Java program should not have to do that. However if it must be done, you can execute commands on a remote server via SSH.

There are multiple libraries for Java that would let you write programs that run commands via SSH. One such library is:

http://www.cleondris.ch/opensource/ssh2/

Java Example with this library:

http://www.informit.com/guides/content.aspx?g=java&seqNum=489


An answer to this question: "How do I set the datetime of a remote machine?" (your question, as I understood it).

Not necessarily a problem which must be solved with a three-tier java stack. If you have an ssh account for the machine, just log in and run date:

$ ssh user@machine.example.com
$ date -s "7 April 2008 20:42:45"

You can run remote commands from your local shell by simply putting ssh in the front, e.g.:

$ ssh user@machine.example.com date -s "7 April 2008 20:42:45"
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜