From owner-freebsd-questions Fri Dec 12 11:18:14 1997 Return-Path: Received: (from root@localhost) by hub.freebsd.org (8.8.7/8.8.7) id LAA16262 for questions-outgoing; Fri, 12 Dec 1997 11:18:14 -0800 (PST) (envelope-from owner-freebsd-questions) Received: from ocala.cs.miami.edu (ocala.cs.miami.edu [129.171.34.17]) by hub.freebsd.org (8.8.7/8.8.7) with SMTP id LAA16255 for ; Fri, 12 Dec 1997 11:18:09 -0800 (PST) (envelope-from jmcla@ocala.cs.miami.edu) Received: from ocala.cs.miami.edu by ocala.cs.miami.edu via SMTP (950413.SGI.8.6.12/940406.SGI) id OAA09171; Fri, 12 Dec 1997 14:17:52 -0500 Date: Fri, 12 Dec 1997 14:17:52 -0500 (EST) From: "Joe \"Marcus\" Clarke" To: Valter Mazzaro cc: freebsd-questions@FreeBSD.ORG Subject: Re: java should execute scripts In-Reply-To: <199712121734.SAA06798@kk660.kk.etx.ericsson.se> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: owner-freebsd-questions@FreeBSD.ORG X-Loop: FreeBSD.org Precedence: bulk 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 >