473,836 Members | 2,139 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

DB2 statements in a batch file + redirect output to file

Hi.
I have 2 DB2 statements:

connect
select

How can I create a batch file and redirect the output to a file?

I would like something like this:

run-select.cmd C:\select-output.txt

TIA

Jan 17 '07 #1
7 31426
Nananana wrote:
Hi.
I have 2 DB2 statements:

connect
select

How can I create a batch file and redirect the output to a file?
I would start with an edito.
Then
db2 -tvf <file output.txt

There also is a -z option with the same effect as >

Cheers
Serge
--
Serge Rielau
DB2 Solutions Development
IBM Toronto Lab

WAIUG Conference
http://www.iiug.org/waiug/present/Fo...Forum2006.html
Jan 17 '07 #2
In article <11************ **********@11g2 000cwr.googlegr oups.com>,
dn***@il.ibm.co m says...
Hi.
I have 2 DB2 statements:

connect
select

How can I create a batch file and redirect the output to a file?

I would like something like this:

run-select.cmd C:\select-output.txt

TIA

Check the docs for a full description about how to use the DB2 Command
Line Processor at http://tinyurl.com/yqxcva
Jan 17 '07 #3
Serge, thanks.
This is what I did:
The batch file has a single line -

db2 connect ...
>From the db2 CLP:
C:\>db2 -tvf c:\db2-dup.cmd

DB21007E End of file reached while reading the command.

Please advice.

Thanks and regards,

Serge Rielau wrote:
Nananana wrote:
Hi.
I have 2 DB2 statements:

connect
select

How can I create a batch file and redirect the output to a file?
I would start with an edito.
Then
db2 -tvf <file output.txt

There also is a -z option with the same effect as >

Cheers
Serge
--
Serge Rielau
DB2 Solutions Development
IBM Toronto Lab

WAIUG Conference
http://www.iiug.org/waiug/present/Fo...Forum2006.html
Jan 22 '07 #4
"Nananana" <dn***@il.ibm.c omwrote in message
news:11******** **************@ q2g2000cwa.goog legroups.com...
Serge, thanks.
This is what I did:
The batch file has a single line -

db2 connect ...
>>From the db2 CLP:

C:\>db2 -tvf c:\db2-dup.cmd

DB21007E End of file reached while reading the command.

Please advice.

Thanks and regards,
When you run a script with "db2 -tvf file-name"
you do not include "db2" in any of the commands within the script. So just
put:

connect to database-name;

in your script (note the semi-colon at the end of each command). This
assumes that you have authority to connect with your current Windows userid,
otherwise you must specify a different user and password in the connect
command.
Jan 22 '07 #5
Great - thanks.
It works now..
Mark A wrote:
"Nananana" <dn***@il.ibm.c omwrote in message
news:11******** **************@ q2g2000cwa.goog legroups.com...
Serge, thanks.
This is what I did:
The batch file has a single line -

db2 connect ...
>From the db2 CLP:
C:\>db2 -tvf c:\db2-dup.cmd

DB21007E End of file reached while reading the command.

Please advice.

Thanks and regards,

When you run a script with "db2 -tvf file-name"
you do not include "db2" in any of the commands within the script. So just
put:

connect to database-name;

in your script (note the semi-colon at the end of each command). This
assumes that you have authority to connect with your current Windows userid,
otherwise you must specify a different user and password in the connect
command.
Jan 22 '07 #6

Excuse me.. more questions.
Now I want to run this *** from a batch file *** (give the customer a
desktop icon).
This is what I get:

C:\>db2 -tvf test.txt
DB21061E Command line environment not initialized.

Please advice.
TIA

Jan 24 '07 #7
You seem to running this from a standard dos prompt command window,
If you need to use the db2 interface, you must do so from a DB2 Command
Window. which has the db2cmd command interpreter active.
On your dos prompt line, issue: db2cmd

This will open a new window which a DB2 command window and where you wil now
be able to issue:
db2 -tvf test.txt
Just make sure that the test.txt file is in accessible within the PATH
statement you are using.
HTH, Pierre.

--
Pierre Saint-Jacques
SES Consultants Inc.
514-737-4515
"Nananana" <dn***@il.ibm.c oma écrit dans le message de news:
11************* *********@k78g2 00...legr oups.com...
>
Excuse me.. more questions.
Now I want to run this *** from a batch file *** (give the customer a
desktop icon).
This is what I get:

C:\>db2 -tvf test.txt
DB21061E Command line environment not initialized.

Please advice.
TIA
Jan 24 '07 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
13508
by: Bob | last post by:
Everybody, I've been doing a lot of on-line research and cannot find any reference to the exact problem I'm having. Let me preface this question with the fact that I'm coming from an Oracle background so my approach may not be the best way to tackle this. However, from the research I have done this approach seems reasonable. Also, I know about the undocumented procedure sp_MSforeachtable. That can give me a
2
1907
by: Jason | last post by:
Hello, I have a class, transCore, that does certain work, and by default, prints its progress to the stand output. Later, I will to write a GUI class that encapsulate the transCore class. I would like to redirect/intercept the output of transCore class to this GUI class. I wrote a sample program that demonstrate how I did it, but I am not sure if it's any good. Can anyone critic my code? If there's any non-standard conforming code or...
10
8180
by: tram | last post by:
How do we pass on the step1 output file to step2 of the same job? I would like to know the current job's output file programmetically, instead of hard coding it. Any idaes would be appreciated. Thanks
3
8598
by: yanakal | last post by:
Hi, I'm using isql to query data and output the same to a flat file. The isql has the following command options ' -h-1 -w500 -n -b -s"" '. In the SQL_CODE, the first two lines before the select statement are use dbname set nocount on go When I run this, an additional blank line is put into the output file. Actually, there are two lines after the last result set in the output file. This file is being fed into another system and the...
3
1299
by: Bret Pehrson | last post by:
Anyone else have this problem? (cpp project) Properties, linker, general, output file, edit Show macros, select any and click click insert -- no action. Anyone else see this? --
2
3704
by: 28tommy | last post by:
Hi there, I'm doing some TELNET and FTP sessions with my scripts. I need to redirect all the output (and not just what I print) to an output file, but still be able to see the session in process on the console. The Console screen is of less importance, so I could give it up, but what I'm looking for is a way to see all the interaction with the remote seesions on a file, that all the console data was redirected to it from within the...
1
2708
by: abcd | last post by:
I have a program which is written in C and interfaced with python via Swig. However, the function I call prints stuff out to the console. I would like to capture what it is printing out. I tried: import MyCProg, sys f = open("tmp.txt", "wb") sys.stdout = f MyCProg.getData()
3
4668
by: undshan | last post by:
I am writing a code that needs to open a file, create an output file, run through my function, prints the results to the output file, and closes them within a loop. Here is my code: #include <stdlib.h> #include <stdio.h> #include <math.h> #include <string.h> #include "util.h" //Main Loop
1
1440
by: Peithon | last post by:
Hi, I want to generate a log file (e.g. output.txt) for debugging output. I want it in my project's debug directory. I can generate the file but not in the right place. I open the project properties page and choose Debugging to get a series of edit boxes, one is called Command Arguments. I enter the following for Command Arguments: This creates the file in
0
9810
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9656
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10241
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9358
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6975
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5642
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5812
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4443
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
3102
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.