Problem in inserting values of variable of shell


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Problem in inserting values of variable of shell
# 1  
Old 08-07-2013
Problem in inserting values of variable of shell

hi all,

i have one shell script like this
Code:
#!/bin/bash -xv
ENV_NAME=`cat $IB_HOME_DIR/cfg/ibProfile.sh | grep "RDM_CONN" | cut -f 2 -d "@"`
CURRENT_DIR=`pwd`;
string=$IB_HOME_DIR
string1="$string/FRGFOLDER/input"
#sed "s/string3/$string1" frg_event_src.sql > modifiedinsert.sql

sqlplus -s rte/rtet2@rel76t2 <<-EOF
set pagesize 0
set linesize 80
set feedback off
set echo off
whenever sqlerror exit sql.sqlcode;
@$CURRENT_DIR/frg_event_src.sql
exit;
EOF

and frg_event_src.sql is like this

Code:
Set define off;
insert into CFG_FRG_EVENT_SRC (FRG_EVENT_SRC_KEY, SWI_ID, FILE_PATH, FILE_NAME_MASK, CONVERTER_NAME, BACKUP, BACKUP_PATH,CVT_FILE_PATH, ERR_FILE_PATH, SEQ_NBR_LWR_LMT, SEQ_NBR_UPR_LMT,KEEP_REC_CAT_STATS, VALIDATE_DETAILS, PROC_ORDER_BY, SEQ_NBR_GAP_TOLERANCE, FILE_DTTM_GAP_TOLERANCE, SEQ_NBR_RANGE_TOLERANCE, ENABLED, MISSING_FILES_DETECT_FLAG, NUM_CYCLES_TO_PROCESS, NUM_FILES_PER_CYCLE, DUP_CHK_SCHM_CODE, DESCRIPTION, USERNAME, GROUPID) values (10000, 'FT_SWI','${string1}','PSTINVOPR1_%4%.idr', 'cvt_passthrough', 1, '$IB_HOME_DIR/FRGFOLDER/backup','$IB_HOME_DIR/output','$IB_HOME_DIR/FRGFOLDER/error',0, 9999, 1, 1, 1, 1, 1, 1, 0, 0, 1, 1, 0, 'PSTINVOPR1', 'SYS', null);
commmit;
~

but the insert query is not being executed.
Can any one please help.......
# 2  
Old 08-07-2013
What is the error shown?

Also you could see if you're getting the proper commands with cat:
Code:
cat <<-EOF
  ....
EOF

Or you could also use here strings:
Code:
sql command <<< "
...
"

# 3  
Old 08-07-2013
Yes, what is the error msg? And, be aware that single quoted shell variables won't be expanded!
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How to assign awk values to shell variable?

Hi Gurus, I have a script which assign awk output to shell variable. current it uses two awk command to assign value to two variables. I want to use one command to assign two values to two variables. I tried the code, but it does't work. kindly provide your suggestion. current code... (2 Replies)
Discussion started by: green_k
2 Replies

2. Shell Programming and Scripting

Inserting values to database

hi , I'm new to Unix shell scripting. I need help to insert read csv which has two columns -emp no and logged date. csv file is a large file so i want to keep the insertion query in a separate .sql file. csv file looks this: empno | loggeddate ___________________ 5666 ,... (5 Replies)
Discussion started by: preema
5 Replies

3. Shell Programming and Scripting

Read in shell variable values from a file

Hello, I have a simple script that runs an application, # these arguments have the same value for all splits ARCH=12.11.1 BATCHES=50 EPOCHS=5000 LEARN_MODE=ONLINE LEARN_RATE=0.25 PROJ=02_BT_12.11.1.proj echo "processing split A on hex" cd A/ DATA_SET=S2A_v1_12.1.1_1... (4 Replies)
Discussion started by: LMHmedchem
4 Replies

4. Shell Programming and Scripting

Inserting variable values in filename

Hi All, I have a directory containing multiple files. and also a txt file which contains the list of all filenames and certain values. I want to read the text file line by line and if its 2nd column is matched with the filename in directory, then it must insert the values in 7th column to... (14 Replies)
Discussion started by: CAch
14 Replies

5. Shell Programming and Scripting

Passing values from awk to shell variable

I am writing a script where I need awk to test if two columns are the same and shell to do something if they are or are not. Here is the code I'm working with: @ test = 0 ... test = `awk '{if($1!=$2) print 1; else print 0}' time_test.tmp` #time_test.tmp holds two values separated by a space... (3 Replies)
Discussion started by: Malavin
3 Replies

6. Shell Programming and Scripting

Store values from a file into an array variable in Shell

Dear All, I have been trying to do a simple task of extracting 2 fields from the file (3 rows) and store it in an array variable. I tried with: #! /bin/bash ch=`cut -f10 tmp.txt` counter=0 for p in $pid do c=${ch} echo "$c ..$counter" counter=$((counter+1))... (2 Replies)
Discussion started by: ezhil01
2 Replies

7. UNIX for Dummies Questions & Answers

Storing values in shell variable

Hi, I am writing a shell script where, x=y y=z When I want to print z, I can do $y How do I use only "x" without any direct reference to "y" to print z? Thanks, -G (3 Replies)
Discussion started by: gaurab
3 Replies

8. Shell Programming and Scripting

Korn Shell Variable values difference

I am using two shell scripts a.ksh and b.ksh a.ksh 1. Sets the value +++++++++++++++++ export USER1=abcd1 export PASSWORD=xyz +++++++++++++++++ b.ksh 2. Second scripts calls sctipt a.ksh and uses the values set in a.ksh and pass to an executable demo... (2 Replies)
Discussion started by: kunalseth
2 Replies

9. Shell Programming and Scripting

problem assigning values to variable

Date of Request: 20080514 10:37 Submitted By: JPCHIANG i want to get the value "JPCHIANG" only in read a file, however, when i do this: name=`"$line"|cut -d " " -f8` it display all the line and append 'not found' at the end of the statement the $line is actually a variable in a... (2 Replies)
Discussion started by: finalight
2 Replies

10. Shell Programming and Scripting

Inserting Values From A File Into A Table

Guys, I want to insert some values from a log file into a temporary table. the values in the log file looks like this SV_NAME CC_NAME CP_DISP_RUN_STATE ------- ------------------- ----------------- sble01 ALLTEL WorkMon24Hrs Running I want to enter the... (2 Replies)
Discussion started by: ragha81
2 Replies
Login or Register to Ask a Question