Teradata BTEQ: disable logon prompt - teradata

When i run a teradata bteq in the CMD shell -
A little logon prompt screen pops up.
When i press enter the bteq runs.
Is there a way to disable this popup screen?
Searching the internet yields that entering a logonprompt off should solve the problem.
Like so:
.SET LOGONPROMPT OFF
.LOGON my_server
-- rest of the bteq script...
.QUIT
.LOGOFF
I use the following shell command to run the bteq:
bteq < myscript.sql > log.txt
Could you please help me get rid of the logon popup screen?

You can pass the fully qualified logon string to get rid of the prompt.
.LOGON my_server/user,password
If you still want to go with only the server details in .LOGON. Along with .SET LOGONPROMPT OFF, set the environment variable GUILOGON as NO.
In CMD: setx GUILOGON NO
Snippet from TD Documentation:
Note that setting LOGONPROMPT to OFF is sometimes not going to be
sufficient for suppressing all unnecessary prompts when using Windows
BTEQ. You may also need to instruct CLI to suppress its generation of
what is known as its GUILOGON dialog box.
This can be accomplished by setting the environment variable GUILOGON
to NO.

Related

How to hide Logon Password in Teradata MLoad Script

I have written a Multiload script to Load Data in TeraData Database and the commands in the script is like:
.LOGTABLE Employee_log;
.LOGON 192.168.1.1/dbc,dbc;
.BEGIN MLOAD TABLES Employee_Stg;
.LAYOUT Employee;
.FIELD in_EmployeeNo * VARCHAR(10);
.FIELD in_FirstName * VARCHAR(30); ....
But the password is clearly visible in the script. Is there a option to secure the password or any alternate way/command to logon and then run the script.
You can create a logon file and run it in your MLOAD script using the following command
.RUN FILE logonfile.txt
In the logon file you can provide the statement that you used in your script .LOGON 192.168.1.1/dbc,dbc;
Restrict access to logonfile.txt, though only the user can read it
chmod go-rwx logonfile.txt
or use tdwallet
.LOGON 192.168.1.1/dbc,$tdwallet(dbc)
tdwallet keeps the entries safely away, only access via logon command.
There is no function to get an entry in cleartext.

Sqlite Mode Error When Running Script with Output Redirection

I have the following shell script
cat <<EOF | sqlite3 /path/to/my/db.sqlite
.mode line;
select item from mytable;
EOF
When running the script with output redirection, I get this error:
Error: mode should be one of: column csv html insert line list tabs tcl
This happens also when I try different modes. When I run the script without output redirection (printing to terminal), it works fine. What's going on?
Figured it out-- actually the same error was being thrown without output redirection, but I was missing it because normal output was being dumped to the screen instead of a file. The problem in my script is that there should be no ; after mode line.

How to run sql script in geany?

I am able to run my ex1.sql script from the command line, but in geany the follow error pops up:
./geany_run_script.sh: 5: ./geany_run_script.sh: ./ex1: not found
Does anyone have an idea?
Geany cannot execute sql directly. You have to configure the Build Commands from inside the build menu to do this e.g. to psql -f %f to run sql script with psql client.
For me to work I did this
modify the filetypes.sql
this way:
[build-menu]
EX_00_LB=_Exécuter
EX_00_CM=/opt/lampp/bin/mysql -u root < %f
EX_00_WD=
/opt/lampp/bin/mysql = is where mysql is install on my computer
< %f = allow the sql to be executed
dont forget to specify whitch DB you want to work with in your code
so put a line like use Mydatabase;
at the top.

Teradata - run a file/script at Unix Linux command prompt

I have the client/TTU installed on Unix box for Teradata.
If I do the following, it works. Where "..." is Teradata BTEQ normal output and once the following is done, I'm back at the prompt.
$ bteq
...
....
. logon dbname/dbuser,dbpassword
SELECT DATE, TIME;
.LOGOFF;
.QUIT;
..
...
$
Now, lets say I put the following lines in a file called "testtd.bteq"
. logon dbname/dbuser,$dbpassword
SELECT DATE, TIME;
.LOGOFF;
.QUIT;
What I want now is ... how can I run this script (.bteq) at Unix $ prompt ???
I tried the following methods so far, but they didn't work, may be Im missing anything:
1. bteq < /path/to/testtd.bteq > testtd.log
2. bteq <
.run /path/to/testtd.bteq
HereDocEndsHere
Any ideas? DO I HAVE to provide ". logon dbname/dbuser,dbpassword" FIRST, if I'm using the HereDocument way?
Running bteq command on $ prompt doesn't even give me any HELP/options that I can use, like other commands.
i.e.
cmd -u user -p password -f file etc...
The best practice I'm aware of is
store your teradata credentials in a ~/.tdlogon file
create a script that contains your bteq call with all the stuff it needs.
E.g., create a file bteqScript.sh with
/* define helper variables, e.g.... */
export ARCHIVEDIR=~/data
export DATAFILE=dataOutput1.txt
bteq <<EOF
.run file=$HOME/.tdlogon
.export data file=${ARCHIVEDIR}|${DATAFILE}
/* sql code on next line(s) */
select
'foo' as "bar"
;
.export reset
EOF
Note that .run file=... executes the .logon command with your credentials, stored elsewhere.
Kudos to Alex Hasha for the bteq script.
PS - It works via method 1 -- when I hard code the password in the script file for LOGON command.
I wanted to do the same via exporting a variable called "dbpassword"
i.e.
$ export dbpassword=xyxyxyxyx
and
then, inside the script file, i can use "$dbpassword" ... in the LOGON command.. somehow export is not exporting the var within .bteq logon command.

Respond to shell prompts from Ant SSH task (SSHEXEC)

I'm using the SSHEXEC ant task to run an SSH script against a remote linux box.
This has worked fine until I try and call a ksh script which prompts the user for input. The script changes the current user (like su). It prompts the user for a change_request_id, and a change_request_reason. So using this command normally in a shell would look like this:
change_user deploy_user
Please enter the changes request number for doing this: 1234
Please enter the changes request reason: Because I can
<deploy_user>
But when I run these commands from SSHEXEC, it gets to the first prompt "Please enter the changes request number for doing this:" and stops. Even though I'm piping a response to this prompt via SSHEXEC, it still gets stuck here.
Unfortunately we do not have access to change or copy the change_user shell script.
I was wondering if there was some way I could use SSHEXEC which would send down prompt answers with the command.
Any help would be appreciated.
Are you able to put another script on the same server as the change user script that accepts command line parameters and then calls the change request script itself? E.g. in ksh:
#!/usr/bin/ksh
#
# $1 is change request number
# $2 is change request reason
#
/path/to/change_request_cmd <<PARAMS
$1
$2
PARAMS
It may be easier to have SSHEXEC call this script instead.

Resources