View Full Version : Java and Unix
ChrisMc
02-09-04, 09:21 AM
Is there any way I could use a java socket to pass parameters and execute unix scripts?
Is there any examples?
stdunbar
02-09-04, 10:41 AM
I'm not sure what you're trying to accomplish exactly but look at Runtime.exec() in the java.lang package. This allows you to run other processes from your Java program and they certainly can be native code or shell scripts.
Is there any way I could use a java socket to pass parameters and execute unix scripts?
Is there any examples?
ChrisMc
02-09-04, 10:47 AM
I'm not sure what you're trying to accomplish exactly but look at Runtime.exec() in the java.lang package. This allows you to run other processes from your Java program and they certainly can be native code or shell scripts.
I have a unix server and I want to be able to run scripts remotely from my machine using a java applet or jsp. Thanks for the information I will look into it.
stdunbar
02-09-04, 11:02 AM
Some of it depends on what your Unix server allows. The "old" way used to be to allow an "rsh" command in. However, the security risks of rsh are often too big to overcome. If you decide to go that route I haven't looked to see if there is a Java rsh client available.
However, if you have JSP's I'd go that route. Have the JSP/Servlet do the Runtime.exec() for you and you can manage security through normal J2EE mechanisms. This will make the front end a simple browser interface instead of a Java applet or application.
I have a unix server and I want to be able to run scripts remotely from my machine using a java applet or jsp. Thanks for the information I will look into it.
hi,
Take the echo server example from the java tutorial and add the Runtime.exec() call as has already been suggested?
But why reinvent the wheel? you can make use of ssh ,telnet (and rsh as already suggested)
vBulletin® v3.6.4, Copyright ©2000-2009, Jelsoft Enterprises Ltd.