Subject Re: Calling isql.exe from a windows batch
Author zsmeier
--- In firebird-support@yahoogroups.com, Mark Rotteveel <mark@...> wrote:
>
> On Wed, 25 Jul 2012 16:06:33 -0000, "zsmeier" <zsmeier@...> wrote:
> > Hi,
> > I have a problem calling isql.exe from a windows batch file, which is
> > called from a running service.
> >
> > I wrote a simple java program, which calls a windows batch script with a
> > parameter:
> > System.exec("c:\Temp\hook.cmd foo").
> >
> > The batch script first writes a select statement into a file using the
> > parameter:
> > echo select if from users where name = 'foo' >> c:\Temp\statement.sql
> > ...and second calls the isql.exe command with the file as input
> > parameter and an output parameter to write the result
> > <PATH_TO_FIREBIRD_BIN>\isql.exe -user sysdba -password masterkey
> > <PATH_TO_DB>\database.fdb -i c:\temp\statement.sql -o c:\temp\result.txt
> > I run this Java program from a console, it works just perfect, I have
> > the results in the result.txt. Great!
> > Installing the Java program as a windows service, the result.txt remains
> > empty. The hook.cmd is called, the statement.sql is generated, but
> > then... there are no results in the result.txt.
> >
> > Has anybody an idea? Had anybody a problem like this?
> > Has this something to do with "current user" if the application runs as
> > a Service (Which is SYSTEM)? There is not possible to connect with isql
> > if the user is not the current windows user?
> >
> > Any help or clue would be greatly appreciated! Thanks.
>
> You might want to look at
> http://www.javaworld.com/jw-12-2000/jw-1229-traps.html
>
> You should also try to read (and log) the output from the error stream and
> output stream exposed by the Process object. Also check if the user running
> the service has read and write access on C:\temp.
>
> BTW: If you are using Java, wouldn't it be easier to just execute those
> statements from within Java using Jaybird?
>
> Mark
>
Hi Mark!
The first batch call from java works. The hook.cmd is called, the statement.sql is generated.
Yes, the Java program uses JDBC to access the database, and write and read to the very same database. The idea of the hook is, that the service makes a lot of things, mostly writes in the db, and when it is done calls the hook saying I'm ready. The hook now can do whatever we need, calling another service, calling another program, getting information the other program needs directly from the database.

Greetings

Zsolt.