Date: Fri, 12 Dec 1997 14:17:52 -0500 (EST) From: "Joe \"Marcus\" Clarke" <jmcla@ocala.cs.miami.edu> To: Valter Mazzaro <teima@kk.etx.ericsson.se> Cc: freebsd-questions@FreeBSD.ORG Subject: Re: java should execute scripts Message-ID: <Pine.SGI.3.96.971212141632.9140A-100000@ocala.cs.miami.edu> In-Reply-To: <199712121734.SAA06798@kk660.kk.etx.ericsson.se>
next in thread | previous in thread | raw e-mail | index | archive | help
I got it to work with a shell script. Here are my Java source and shell script. Be sure the script has executable permissions. import java.io.*; public class execTest { public static void main(String argv[]) { //String myString[] = {"CC", "-o", "/home/escambia/jmcla/src/crypt_test", "/home/escambia/jmcla/src/crypt_test.C"}; String myString[] = {"/home/escambia/jmcla/testscript"}; try { Process rt = Runtime.getRuntime().exec(myString); } catch (IOException ie1) { System.out.println("Oops!"); } } } #!/bin/csh -f CC -o /home/escambia/jmcla/src/crypt_test /home/escambia/jmcla/src/crypt_test.C This worked great. Hope this helps. Joe Clarke On Fri, 12 Dec 1997, Valter Mazzaro wrote: > Hi, > I'm quite new in using java! > I wonder how it's possible to run unix scripts from java. > I know that I can run an executable file by running rt.exec command, > for example rt.exec("dhcpconf le0 release"), but if I create a script, > let's say stopDHCP that contains just the line:dhcpconf le0 release > the command rt.exec("stopDHCP") doesn't work. > Any hint? > Thanks > Valter >
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?Pine.SGI.3.96.971212141632.9140A-100000>