Article View: borland.public.jbuilder.java.language
Article #15089Re: How can I put a command to the external process by use getOutputStream()?
From: Tom Davies
Date: Sat, 17 Jul 1999 00:00
Date: Sat, 17 Jul 1999 00:00
48 lines
2061 bytes
2061 bytes
Kevin,
The process you start with 'runtime.exec(init)' is expecting to read a
command from standard input is it?
That is, if I type at a shell:
>begin_command
second_command
Then begin_command will read second_command and do whatever it is you
want it to do?
Tom
Kevin wrote:
>
> Hi,
> It's there again! I try to run a external process writen by C, so I use
> Runtime() and get its getInputStream().... The first time when I put the
> "begin_command" I really get the result from vprocess, and I hope the
> vprocess would wait for the "second_command" then continue to finish its
> process. I write the code below:
>
> String init = begin_command;
> try
>
> Runtime runtime = Runtime.getRuntime();
> Process vprocess = runtime.exec(init);
> is = new DataInputStream(vprocess.getInputStream());
> br = new BufferedReader(new InputStreamReader(is));
> os = new DataOutputStream(vprocess.getOutputStream());
> pr = new PrintWriter(new OutputStreamWriter(os),true);
> } catch (IOException e) {}
>
> public void do()
> String readin;
> try
>
> pr.write(second_command);
> while((readin = br.readLine()) != null)
>
> System.out.println(readin);
> }
> } catch (IOException e) {}
> }
>
> But I found "second_command" cannot be accept by vprocess, so I got nothing.
> Where's wrong and how can I do?
> Thanks advance!
Technical Details
Message-ID:
<378FD685.23B6340A@smartchat.net.au>Path:
arc1-ca.pugleaf.net!unknown!not-for-mailReferences:
<7mmian$76n3@forums.borland.com>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: f74b3,96057074d0c2a5da X-Google-Attributes: gidf74b3,public From: Tom Davies <tom@smartchat.net.au> Subject: Re: How can I put a command to the external process by use getOutputStream()? Date: 1999/07/17 Message-ID: <378FD685.23B6340A@smartchat.net.au> X-Deja-AN: 501739214 Content-Transfer-Encoding: 7bit References: <7mmian$76n3@forums.borland.com> To: Kevin <kevin1645@gcn.net.tw> Content-Type: text/plain; charset=us-ascii Organization: Another Netscape Collabra Server User Mime-Version: 1.0 Newsgroups: borland.public.jbuilder.java.language