🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.jbuilder.java.language
Article #14923

Re: How can I put a command to the external process by use getOutputStream()?

#14923
From: Kevin
Date: Mon, 19 Jul 1999 00:00
66 lines
2799 bytes
Tom,
    Thanks for your help, first.
The situation is, I am writing a UI and want to show a C program running
results. Everything is ok but the interactive mode of that C program. I
integrate the C program with a vprocess, first, I transfer a command string
(init = v.exe + interactive_option) than input this string to the vprocess,
I really get the first step of the result, now I don't know whether the
vprocess is alive or not, than I type the second_command at a shell, but it
show nothing on the screen.
>....(results of first step)
>second_command
>
Should I use a pipe or other method to reach the purpose? Thank you for your
help and I hope you can tell me something to do.
Kevin

Tom Davies ���g��峹 <378FD685.23B6340A@smartchat.net.au>...
>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: <7mtv8j$dkv8@forums.borland.com>
Path: arc1-ca.pugleaf.net!unknown!not-for-mail
References: <7mmian$76n3@forums.borland.com> <378FD685.23B6340A@smartchat.net.au>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII
X-Google-Thread: f74b3,96057074d0c2a5da
X-Google-Attributes: gidf74b3,public
From: "Kevin" <kevin1645@gcn.net.tw>
Subject: Re: How can I put a command to the external process by use getOutputStream()?
Date: 1999/07/19
Message-ID: <7mtv8j$dkv8@forums.borland.com>
X-Deja-AN: 502559224
References: <7mmian$76n3@forums.borland.com> <378FD685.23B6340A@smartchat.net.au>
Organization: Avery
X-MimeOLE: Produced By Microsoft MimeOLE V4.72.3110.3
Newsgroups: borland.public.jbuilder.java.language