Hi susan,
I have successfullly ran a shell script with the following command
and now we have running a deamon too with this command, hope this snippet
shall help u
**********
Process proc = Runtime.getRuntime().exec("sh ss.s");
BufferedReader br = new BufferedReader(new InputStreamReader(proc.getInp
utStream()));
String line = "";
while ((line = br.readLine()) != null)
{
System.out.println(line);
}
}
Srini
#-----------------------------------------------------------------------#
# #
# "ARISE AWAKE and stop not till the GOAL is reached" #
# #
# [EMAIL PROTECTED] #
#-----------------------------------------------------------------------#
On Wed, 4 Aug 1999, Susan Moffat wrote:
> Hi
>
> I'm trying to perform unix commands from my Java program and have tried
> using the Runtime class as follows:
>
> Process proc = Runtime.getRuntime().exec("/bin/sh -c \"ls;pwd\"");
>
> to try to perform more than one command in the same runtime instance.
> Apparently calling exec again will result in a new process being ran and as
> I'm trying to perform the commands using the same instance (I'll actually be
> trying to use the "su" command and perform several commands whilst as the
> superuser).
>
> I've also tried writing to the returned Process class's output stream by
> using a BufferedWriter taking an OutputStreamWriter from the
> Process.getOutputStream() method - to no avail. As when I perform the
> flush() on the writer, an IOException occurs with a write error thrown in
> the FileOutputStream.write() method, which flush() inherits from.
>
> Has anyone managed to perform operating system commands from within their
> Java code?
>
> Thanks, Susan
>
> ___________________________________________________________________________
> 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
>
___________________________________________________________________________
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
Re: Process and Runtime classes
Srinivasan S (Systems Engineering Group) Wed, 4 Aug 1999 18:38:37 -0700
- Process and Runtime classes Susan Moffat
- Re: Process and Runtime clas... Ricky Szeto - CSCI/F95
- Re: Process and Runtime clas... Milt Epstein
- [Offtopic] Re: Process and R... Steve Odendahl
- Re: Process and Runtime clas... Srinivasan S (Systems Engineering Group)
- Re: Process and Runtime clas... Mukul Gandhi
- Re: Process and Runtime ... Chris Pratt
- Re: Process and Runt... Mukul Gandhi
- Re: Process and Runtime ... Srinivasan S (Systems Engineering Group)
