Your code will not work. The environment settings created by
/opt/bin/coraenv are local to the subprocess, and won't carry over to
the sqlplus command.
It's true that /opt/bin/coraenv will prompt for ORACLE_SID if it's not
in the environment... it would help to create a copy of this file,
setting just the environment variables you need.
Try something like:
String[] cmds = {"/usr/bin/csh", "-c", "source myoraenv; sqlplus"};
Process process = Runtime.getRuntime().exec(cmds);
where "myoraenv" contains your Oracle environment settings.
Sam Rose wrote:
>
> I've tried this...
> but it doesn't like my source, probably because I need to return this
> value, i.e. hit the enter button after this, is there a bit of code
> that I can achieve this with?
>
> String command ="source /opt/bin/coraenv";
> String runsql = "sqlplus";
>
> Runtime runtime = Runtime.getRuntime();
> Process process = null;
> Process sql = null;
>
> try {
> process = runtime.exec(command);
> sql = runtime.exec(runsql);
> }//end try
>
> this brings up
>
> java.io.IOException: source: not found
>
> -----Original Message-----
> From: Jeff Sturm [mailto:[EMAIL PROTECTED]]
> Sent: Wednesday, June 16, 1999 4:13 PM
> To: [EMAIL PROTECTED]
> Subject: Re: running SQL PLus via a servlet on unix
>
> You should be able to do the same... the Process class works
> similarly
> on Unix. Either source the environment variables from the script
> that
> starts your servlet engine, or wrap sqlplus in a shell script that
> first
> sources the variables, then invoke the script from Runtime.exec(...).
>
> (Out of curiousity, why would you want to run sqlplus from Java when
> you
> can use JDBC?)
>
> Sam Rose wrote:
> >
> > Hello,
> >
> > I'm trying to execute SQL*PLUS with a servlet on unix.
> >
> > Windows I used this code...
> >
> > String command ="Plus80w";
> >
> > Runtime runtime = Runtime.getRuntime();
> > Process process = null;
> > try {
> > process = runtime.exec(command);
> > }//end try
> > catch (Exception e) {
> > out.println("Problem with SQL Plus: " + e);
> > }//end catch
> >
> > but I'm not sure how, as now my servlet's are on unix, to run
> > SQL*PLUS.
> >
> > I now that I have to setup my source which is
> > source /opt/bin/coraenv
> >
> > but then I'm not sure how to do this in a servlet and then also how
> to
> > start SQL*PLUS.
> >
> > Any help will greatly be appreciated.
> >
> > Cheers
> >
> > Sam
> >
> >
> _______________________________________________________________________
> ____
> > 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
>
> --
> Jeff Sturm
> [EMAIL PROTECTED]
>
> _______________________________________________________________________
> ____
> 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
--
Jeff Sturm
[EMAIL PROTECTED]
___________________________________________________________________________
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