Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Runtime.exec() and interacive programm

Status
Not open for further replies.

chenn

Technical User
Nov 9, 2000
106
0
0
DE
Hi,
i'm trying to execute programms via Runtime.exec(cmd, envp, dir) which works just fine for DOS batches, Java-Tools and the like.
Problem are semi-interactive programms such Oracle's sqlplus. You can start it with an optional configuration file and thereby make it _not_ interactive. however if there is an error in the configuration file it crashes and Runtime.exec() hangs not displaying the error message or logging it to a textfile.
How can I avoid that - how can I add interactivity to Runtime.exec() calls?
Any hints welcome.


regards
chenn
 
You can read/write via InputStream and OutputStream to the Process object created by Runtime.exec() ...
 
I think if you want to interact with Oracle from java, is better to use jdbc.

Ion Filipski
1c.bmp
 
i have to add some further information, as jdbc won't solve any problems over here.
i'm executing an external tool - a *.exe application - from a java application. what i need to do is capture its output and log it - which works fine alltogether - plus i need to react to user dialogs - the problem.
Imagine the tool prompts for a password. i can't see that, as my java exec-call is one subprocess starting another process - the *.exe application itself.
how do i monitor its output?

regards
chenn
 
Using Runtime.exec() you can capture output from stderr, stdin and stdout - but not from the GUI's own text/password fields. If you tell us a little more about why you must run a GUI app from a java app ?
 
well i'm writing a tool for data migration projects, that uses xml for configuration files. the configuration file contains programms to be called, etc. it is basically like a batch-script, it just needs to be xml.
when processing the xml-file, there might be some semi-interactive programms executed, like the Oracle sqlloader or Oracle sqlplus to perform database operations. these usually pick their configuration files and work just nice, but if not i need to log/monitor/display the errors.
so far if a programm such as the sqlplus waits for input (e.g. reprompting a username/passwort), the java tool also "hangs" (in fact it is waiting for subprocess termination).
e.g. a wrong username/password combination passed to a programm doesn't make it exit with some queer exit value, but reprompt for username and password.
my idea was capturing the dialogs of the programm to be executed via the java console to avoid these hang-ups.


regards
chenn
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top