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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Command line environment not initialised

Status
Not open for further replies.

markgargan

Programmer
Apr 4, 2005
25
IE
Hey folks,

I'm currently trying to write a db2 script.

I've got a number of commands back to back like follows

db2 attach to db2;

db2 connect to sample;

db2 -r authors.txt select * from authors;

db2 disconnect sample;

db2 detach;

db2 terminate;

However as soon as the script tries to invoke the first command I get the following error:-

DB21061E Command line environment not initialised

I've moved all the commands to a .db2 file removing the
'db2' prefix from each and then called them using the
db2cmd.exe executable.
This works however the most important part of the script is
the redirection.

I've read some of the docs on the CLP and it says :-
"Maintaining Database Connections

Each time that db2 is invoked, a new front-end process is started. The back-end process is started by the first db2 invocation, and can be explicitly terminated with TERMINATE. All front-end processes with the same parent are serviced by a single back-end process, and therefore share a single database connection.

For example, the following db2 calls from the same operating system command prompt result in separate front-end processes sharing a single back-end process, which holds a database connection throughout: "


Basically that by invoking DB2 attach that the db2bp process should maintain the connection.

Does anyone know how to get around this issue? As it seems fairly fundamental to writing db2 scripts.

Thanks,
Mark.
 
Mark,

I think you are simply invoking the windows/dos command prompt in which you're running your script. Try running through the DB2 Command Window and I think the DB2 error message will not happen.

You can invoke this from selecting DB2, Command Line tools, Command window.

Cheers
Greg
 
Hey Greg,

Thanks for getting back to me Greg.
The problem was that I needed to be able to run a script that
would allow me to perform commands like

db2 attach to sample

i.e. with the db2 at the start because I needed the redirection option before a certain select command so that
I wouldn't have to parse the output file myself to retrieve
the table result set.

So eventually I copped on that if I just used the file option with a .bat file I could put whatever commands I liked in there.

Thanks Greg,
Mark
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top