Calling one command with the exec does work - I'd already tried that - it
does seem to have trouble dealing with further commands and seems to ignore
them. I've tried the method suggested below which is similar to my previous
attempts, which still didn't work - I think it probably should though -
although using PrintStream stopped the exception being thrown which is an
improvement. I've tried Srini's idea of running a script and that works.
Thanks for all your help and suggestions, Susan
-----Original Message-----
From: Steve Odendahl <[EMAIL PROTECTED]>
To: [EMAIL PROTECTED] <[EMAIL PROTECTED]>
Date: Thursday, August 05, 1999 12:47 AM
Subject: [Offtopic] Re: Process and Runtime classes
>Another possibility might be to just exec the shell, and use the
>OutputStream from the Process to send commands to the shell - e.g.
>
>
>Process shell = Runtime.getRuntime().exec("/bin/sh");
>PrintStream out = new PrintStream (shell.getOutputStream (), true);
>DataInputStream in = new DataInputStream (shell.getInputStream ());
>String line = null;
>
>out.println ("ls");
>while ((line = in.readLine ()) != null)
>{
> // Do something with it
>}
>
>out.println ("pwd");
> .
> .
> .
>out.println ("exit");
>
>
>I have no idea if this would work, but I don't know any reason why not.
>(I'd be curious to know if there is a reason.)
>
> Steve Odendahl
> Vunetix, Inc.
___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".
Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html