Calling Power Shell Script from within Bteq script

Database
Fan

Calling Power Shell Script from within Bteq script

Hello there,

I hava a Bteq script which does some conditin checking and if the first condition met , it should invoke a powershell script for sending out emails Or exit. I am running on windows.

I am getting error on the line where I am calling the power shell script.

I have something like below:

.if activitycount >0 then EXEC powershell.exe-ExecutionPolicy RemoteSigned- File filepath

.Exit

I've also tried .OS command, .OS Exec, .OS call, .OS ; none of them are working.

Any help would be greatly appreciated.

Thanks a lot

Tags (2)
3 REPLIES
Enthusiast

Re: Calling Power Shell Script from within Bteq script

Can you try with both OS and SYSTEM too like:

.SYSTEM 'cmd /c F:\your_directory\...\abc.exe';

Try with just one command , maybe like copy abc file to another directory.

Also try to run the os command independently, without TD script to verify it works. Step-by-step helps :).

Have a look at this link too.

http://www.info.teradata.com/HTMLPubs/DB_TTU_14_00/index.html#page/Load_and_Unload_Utilities/B035_24...

Cheers,

Fan

Re: Calling Power Shell Script from within Bteq script

Thanks Raja. Yes I checked the powershell script outside of Bteq and its working fine.

It's still not working when calling from the Bteq script.

I tried the following:

1) .if activitycount >0 then .os command C:\windows\system32\windowspowershell\v1.0\powershell.exe 'E:\folder1\folder2\myscript.ps1'

2) .if activitycount >0 then .os C:\windows\system32\windowspowershell\v1.0\powershell.exe 'E:\folder1\folder2\myscript.ps1'

3) .if activitycount >0 then .os EXEC C:\windows\system32\windowspowershell\v1.0\powershell.exe 'E:\folder1\folder2\myscript.ps1'

4) .if activitycount >0 then .os system C:\windows\system32\windowspowershell\v1.0\powershell.exe 'E:\folder1\folder2\myscript.ps1'

5) .if activitycount >0 then .os C:\windows\system32\windowspowershell\v1.0\powershell.exe

None of the above are working; saying "system call failed".

Have anyone done something similar, like invoking unix shell script from bteq script ?

Thanks,

Fan

Re: Calling Power Shell Script from within Bteq script

Hi,

It worked !!

here is what worked for me:

.if activitycount >0 then .os CMD/c C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -executionpolicy remotesigned -File E:\your_folder\..\yourscript.ps1

Thanks Raja !