Calling BTEQ with file within PowerShell

Tools & Utilities
Not applicable

Calling BTEQ with file within PowerShell

Hi,

Currently, I execute BTEQ scripts via a generated .Bat file with each script having a call to BTEQ similar to below:

bteq <Bteq\"File_1.btq" >> bteq_output.txt 2>&1

I am trying to create the same functionality but using PowerShell instead. The problem I am facing is the "<" character in the call. The BTEQ cmd line call to my knowledge, uses this to identify an input file. In PowerShell, this is an operator which with the following PowerShell command

(Get_Content -Path $configFile) | Select-Object -Skip 1 | ForEach-Object { bteq < (Join-Path $deployDir $_) >>bteq_output.txt }

Causes the following error:

+  ... ect { bteq.exe < (Join-Path $deployDir $_) >>bteq_output.txt }

+

The '<' operator is reserved for further use.

I have tried escaping the < with the PowerShell escape character ` to no avail. Either it has the < in the call which PowerShell doesn't like or any combination of input does not get picked up as an input parameter to the call for bteq to execute the script that I am trying to run.

Any help would be most appreciated.

Regards,

Jamie

2 REPLIES
Enthusiast

Re: Calling BTEQ with file within PowerShell

Happened to me too I use the Powershell "cat" command

cat myfile.btq | bteq
Teradata Employee

Re: Calling BTEQ with file within PowerShell

The following cat command can be used to run a BTEQ script using PowerShell:

cat "C:\FileLocation\FileOrScriptToRun" | bteq .logon TPID,Hostname,IP/UserName,Password

 

The double quotes are needed if the path has a space within it.  In the BTEQ section the TPID, hostname or IP can be specified.  You only need to utilize one.  After the slash the username and password are specified.  A comma is needed to seperate the two strings.   I haven't used additional parameters with it, but it should work as long as it is a valid BTEQ command.  

 

 

Thanks,

Tom