passing a value from command line into loader


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting passing a value from command line into loader
# 1  
Old 08-14-2006
passing a value from command line into loader

I am calling a loader from Unix shell script, and thus want to pass the $data_file based on the return parameter of
ls -lrt /export/home/sanjit *.txt |cut -c55-120
can any one help me in how to map this value with the data_file.

Assuming everytime, there would be one file in the directory and this will be the input for the loader.

My code is :
Code:
# Initialise location specific environment variables
echo " INITIALISE LOCATION SPECIFIC ENVIRONMENT VARIABLES" 
ORA_USER_PASS=$1
USERID=$2
USERNAME=$3
REQUESTID=$4
P_INPUT_DIR=`echo $5`

# ------------------------------------------------------------------

    echo "Start execution of SQL*Loader routine" $LOADER1 >>  $REPFILE   

    $ORACLE_HOME/bin/sqlldr USERID=$ORA_USER_PASS CONTROL=$CTLDIR/$LOADER1.ctl LOG=$LOGDIR/$LOADER1.log BAD=$BADDIR/$LOADER1.bad SKIP=1 ERRORS=0 DATA=$DATDIR/filenames.dat >>$REPFILE

    echo "Checking for Loader Status " >>  $REPFILE
    if test $? = 0
    then
        echo "Successful termination of SQL*Loader "$LOADER1  >> $REPFILE
        grep "successfully loaded." $LOGDIR/$LOADER1.log >> $REPFILE
        grep "not loaded due to data errors" $LOGDIR/$LOADER1.log >> $REPFILE
        grep "not loaded because all fields were null" $LOGDIR/$LOADER1.log >> $REPFILE
    else 
	echo "Loader has some problems " >>  $REPFILE       
	PROBLEMS=1
    fi

How should we replace the value for filenames.dat with the return of 'ls -lrt /export/home/sanjit *.txt |cut -c55-120'
Thanks in advance
reagrds
# 2  
Old 08-14-2006
Try :

Code:
$ORACLE_HOME/bin/sqlldr ... DATA=$(ls -lrt /export/home/sanjit *.txt |cut -c55-120)  ...


Jean-Pierre.
# 3  
Old 08-14-2006
unknown LTR

This is not working ....the command line can not recognizing ltr...

Can we set somewhere and then pass in command line

thanks & regards


Code:
LRM-00101: unknown parameter name 'lrt'

SQL*Loader: Release 8.0.6.3.0 - Production on Mon Aug 14 08:41:19 2006

(c) Copyright 1999 Oracle Corporation.  All rights reserved.

SQL*Loader-100: Syntax error on command-line

# 4  
Old 08-14-2006
The syntax $(...) is valid with KSH and BASH.
With other shell, use the `...` syntax :
Code:
$ORACLE_HOME/bin/sqlldr ... DATA=`ls -lrt /export/home/sanjit *.txt |cut -c55-120`  ...


Jean-Pierre.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Passing command line parameters into script

Not a good post. (1 Reply)
Discussion started by: bash_in_my_head
1 Replies

2. Shell Programming and Scripting

Passing Command Line Args in a Single Variable?

Hello All, I have a Bash Script and an Expect script that together will SSH to another server and do some stuff there... From within the Bash Script I process the Command Line Arguments, which are Required Args and Optional Args. When I call the Expect script from the Bash Script, I pass... (4 Replies)
Discussion started by: mrm5102
4 Replies

3. UNIX and Linux Applications

Passing date parameter on Kshell command line

I need to execute a .ksh from command line. The ksh calls a control file and has 3 parameters. First parameter is a csv file, second the target table in oracle and third parameter is a date parameter. I am attempting the below from the ksh command line {code} => testfile.ksh filname.csv... (1 Reply)
Discussion started by: kobe24
1 Replies

4. Shell Programming and Scripting

Passing value as a command line argument in awk script.

I have one working awk command line. Which taking data from the “J1202523.TXT” file and generating the “brazil.dat” file. PFB code. awk '{ DUNS = substr($0,0,9);if ( substr($0,14,3) == "089" ) print DUNS }' J1202523.TXT > Brazil.dat But now I want to pass two parameter as a command line argument... (4 Replies)
Discussion started by: humaemo
4 Replies

5. Shell Programming and Scripting

FTP command line username and password passing

Dear All, I am new to unix and I am trying to build a shell script which will connect to a different server by passing username and password from a file or command line but not manually... In short I dont want to connect to a diff server via ftp interactively. Any suggestion...looking... (8 Replies)
Discussion started by: Pratik4891
8 Replies

6. UNIX for Dummies Questions & Answers

Passing command line argument between shell's

Hi, I am facing a problem to pass command line arguments that looks like <script name> aa bb "cc" dd "ee" I want to pass all 5 elements include the " (brackets). when I print the @ARGV the " disappear. I hope I explain myself Regards, Ziv (4 Replies)
Discussion started by: zivsegal
4 Replies

7. Shell Programming and Scripting

Need Help with the argument passing Through Command line

$$$$$ (5 Replies)
Discussion started by: asirohi
5 Replies

8. Shell Programming and Scripting

passing a command line argument

I have a shell script which does the encryption of a file where i am passing the file name as a command line argument,but later on the script waits on the screen to enter Y or N what is the command i should be using on the shell script #!/bin/bash -x outfilename=file.out echo... (8 Replies)
Discussion started by: rudoraj
8 Replies

9. Shell Programming and Scripting

passing command line parameters to functions - sh

All, I have a sh script of the following tune: function a () { #functionality.. } function b () { #functionnlity.. } function check () { # this function checks for env and if all fine call build } function usage () { #sh usage details } function build () { #calls either a or b or... (5 Replies)
Discussion started by: vino
5 Replies

10. Shell Programming and Scripting

Passing the command line argument in a variable

Hi, I am new to unix. Is their a way to pass the output of the line below to a variable var1. ls -1t | head -1. I am trying something like var1=ls -1t | head -1, but I get error. Situation is: I get file everyday through FTP in my unix box. I have to write a script that picks up first... (1 Reply)
Discussion started by: rkumar28
1 Replies
Login or Register to Ask a Question