BTEQ script in BAT file

General
General covers Articles, Reference documentation, FAQs, Downloads and Blogs that do not belong to a specific subject area. General-purpose Articles about everything and anything
Enthusiast

BTEQ script in BAT file

 

Hi All,

 

I have written a BTEQ script in BAT  file but when i double click this BAT file , it does not run and it only runs through command prompt in BTEQ mode.

 

Actually i am trying to run this BAT file through task scheduler so is there a way to run this BTEQ script in this BAT file in an automated way.

 

Thanks


Accepted Solutions
Teradata Employee

Re: BTEQ script in BAT file

Not sure what you are referring to as "BTEQ mode". The bteq script itself is not a valid .bat file, use some other extension for that.

 

The .bat file should have the "bteq" command with stdin redirected from the bteq script file.

For example, the batch file could be something like this:

bteq <bteq-script-file-name 2>&1 >output-log-file-name

 

(The 2>&1 redirects stderr to stdout so you capture any error messages in a single log, along with normal output.)

 

1 ACCEPTED SOLUTION
6 REPLIES 6
Teradata Employee

Re: BTEQ script in BAT file

Not sure what you are referring to as "BTEQ mode". The bteq script itself is not a valid .bat file, use some other extension for that.

 

The .bat file should have the "bteq" command with stdin redirected from the bteq script file.

For example, the batch file could be something like this:

bteq <bteq-script-file-name 2>&1 >output-log-file-name

 

(The 2>&1 redirects stderr to stdout so you capture any error messages in a single log, along with normal output.)

 

Enthusiast

Re: BTEQ script in BAT file

 

Thanks Fred for the details.

 

It is now running but when i run it through task scheduler the script does not run.

 

Any suggestions.

Teradata Employee

Re: BTEQ script in BAT file

I would need more information as to the nature of the failure.

Did you check the History tab in Task Scheduler (or use the Windows Event Log viewer)?

Was the batch file launched? Was BTEQ invoked?

Enthusiast

Re: BTEQ script in BAT file

 

It worked when i gave complete path in the script.

 

Enthusiast

Re: BTEQ script in BAT file

I am having the same issue. When I run individually the .bat file runs. But when I run in the scheduler I get error "'bteq' is not recognized as an internal or external command,
operable program or batch file."

 

my .bat file has:

 

echo off

bteq < C:\Users\u374226\Documents\chan\awp_bteq.txt 2>&1>C:\Users\u374226\Documents\chan\awp_bteq.txt_output.txt 2>&1

@echo off goto end
:end @echo exit

 

Task Scheduler snapshot.PNG

 

Any kind of help or suggestions is really appreciated.

 

Thanks

Chandrika Pai

Teradata Employee

Re: BTEQ script in BAT file

This is a Windows question and not a Teradata or BTEQ question.

When launched by Task Scheduler, the script does not have your user's environment settings.

You may need to specify the full path to bteq.exe, or to explicitly add the Teradata client "bin" directory to the PATH in the script itself (or perhaps add to the system environment PATH and reboot).