-2

Can any one please explian me the below bteq code.

Is this script valid?

exec 1> $CODE/edlr2/logs/AGP_MBR_BTEQ_CSA_MBR_STG_LOAD_$(date +"%Y%m%d_%H%M%S").log 2>&1`echo "script file =" $0 PARM_FILE=$1 echo "parm file= "$PARM_FILE.parm . $CODE/edlr2/scripts/$PARM_FILE.parm select name from customer;

Can anyone please explain this code

XYZ
  • 27
  • 6
  • 1
    Questions seeking debugging help ("**why isn't this code working?**") must include the desired behavior, a specific problem or error and the shortest code necessary to reproduce it **in the question itself**. Questions without a **clear problem statement** are not useful to other readers. See: [How to create a Minimal, Complete, and Verifiable example](https://stackoverflow.com/help/mcve). – Xander Luciano Mar 16 '18 at 07:14
  • I am not understanding this code, which is written by someone else. Can you please explain what is happening here – XYZ Mar 16 '18 at 07:21
  • That's not a BTEQ script, it's a *shell script* probably creating a script which is submitted with BTEQ later – dnoeth Mar 16 '18 at 08:06
  • is echo bteq script command, or it is linux command. is it valid here – Can i run this query on bteq – XYZ Mar 16 '18 at 11:22

2 Answers2

0

See: https://superuser.com/questions/436586/why-redirect-output-to-21-and-12

exec 1> $CODE/edlr2/logs/AGP_MBR_BTEQ_CSA_MBR_STG_LOAD_$(date +"%Y%m%d_%H%M%S").log

This writes to a log file

2>&1 `echo "script file =" $0 PARM_FILE=$1 echo "parm file= "$PARM_FILE.parm . $CODE/edlr2/scripts/$PARM_FILE.parm select name from customer;

2>&1 points the file descriptor #2 to where #1 (above) is already pointing (the .log file).

However it looks like you're missing an ending grave ` somewhere above since you start one before echo but never close it. So I don't think that script is valid. But I also know nothing about how your database is setup to evaluate if the rest is valid. Unless you can give specific errors and information about how your files are setup and doing, it's hard to help you.

Additional info: exec will run a script at a location, and so part:

echo "script file =" $0 PARM_FILE=$1 echo "parm file= "$PARM_FILE.parm . $CODE/edlr2/scripts/$PARM_FILE.parm select name from customer;

is essentially running a command script and logging it to a log file. It would output and run something like:

script file=/var/somefile
parm file=/var/someparms.parm
. /var/anotherparmfile.parm select name from customer;

What is exec

What is a dot command

Xander Luciano
  • 3,753
  • 7
  • 32
  • 53
0

As is, it is neither a unix script, nor some code, nor something bteq could use.

My guess would be, your 'script' looks like this (dismissed the lonely ` as typing error)

exec 1> $CODE/edlr2/logs/AGP_MBR_BTEQ_CSA_MBR_STG_LOAD_$(date +"%Y%m%d_%H%M%S").log 2>&1
echo "script file =" $0
PARM_FILE=$1 
echo "parm file= "$PARM_FILE.parm 
. $CODE/edlr2/scripts/$PARM_FILE.parm select name from customer;

As @Xander already guessed it would redirect output to a log-file and print info about script and logfile name and then execute the script $PARM_FILE.parm with some parameters.

Further guessing, because BTEQ is mentioned in the name for the log file, in that .parm script bteq may be used to execute a SQL-command which is passed to it as parameters.

bteq needs a logon command. If that is added in the .parm script, before the concatenated parameters, and that passed to bteq, you may get some meaningfull response.

Be aware, that the ; at the end would never be passed to the script. The shell would take it as end of command token. And the .parm script would have to add the ; too to construct a valied SQL-command.

Why a dot-command is used to execute a script, which is named .parm is beyond my imagination.

ULick
  • 969
  • 6
  • 12