Sponsored Content
Operating Systems Linux Red Hat Reading csv and executing queries Post 302843365 by ramsavi on Tuesday 13th of August 2013 03:04:05 AM
Old 08-13-2013
Hi,
i used the previous script to compare to the values returned by the query with the values in the csv file.like this
Code:
!/bin/bash
hdr=1
while IFS=',' read -r f1 f2 f3 f4
do      if [ "$hdr" ]
        then    # Skip the 1st line from the input file.
                hdr=""
                continue
        fi

        Tid=$f
        table=$f2
        query=$f3
        value=$f4
val_1=$( sqlplus -s rte/rtet2@rel76t2 << EOF
set heading off
set feedback off
$query from $table;
EXIT
EOF
)
val_4=`echo $val_1 | tr '\n' ' '`

echo "val_5 : $val_4 "
if [ $val_4 == $value ]
then
   echo "test pass"
else
   echo "test fail"
fi

done < excel.txt


it gave the result like this

Code:
val_5 : EXINZTE
test pass
val_5 : 1
test pass
val_5 : SP2-0042: unknown command "from " - rest of line ignored.
./read.sh: line 24: [: too many arguments
test fail
val_5 : SP2-0042: unknown command "from " - rest of line ignored.
./read.sh: line 24: [: too many arguments
test fail

but i only want the result like this

Code:
val_5 : EXINZTE
test pass
val_5 : 1
test pass

but why two more values are compared , how to resolve it

---------- Post updated at 02:04 AM ---------- Previous update was at 02:02 AM ----------

the csv file used is like this

Code:
Tid,table,query,values
1,PRD_FRG_FILE_JRNL,SELECT SWI_ID,EXINZTE
2,PRD_FRG_FILE_JRNL,SELECT CONVERTED_RECS,1

 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

bash: executing commands and reading exit vals

I have a function that returns a bunch of exit codes, say func1, and in my code I'm trying to execute that function in an if statement. This is the closest I could get. f1call=`func1 $arg1 $arg2` if ]; then ... fi When I run the script the function never gets called. What's the right way... (7 Replies)
Discussion started by: eur0dad
7 Replies

2. UNIX for Dummies Questions & Answers

Sh Shell Script executing remote SQL queries

Hi there folks, I am trying to execute remote sql queries on an Oracle server. I would like to save the result of the executed sql queries on a text file, and send that text file as an attachment to an email address. Could anyone give me an idea on how the above could be achieved? Any help... (2 Replies)
Discussion started by: Javed
2 Replies

3. Shell Programming and Scripting

executing scripts by reading names from a file

file.txt contains ------------------ sat1 1300 sat2 2400 sat3 sat4 500 I need to write a shell script that will output like the below #output sat1.ksh 1300 sat2.ksh 2400 sat3.ksh sat4.ksh 500 my try ------- #!/bin/ksh for i in `cat file.txt` (3 Replies)
Discussion started by: konark
3 Replies

4. Shell Programming and Scripting

Executing informix queries using isqlrf

Hi, I have my informix queries in files named sql1.sql and sql2.sql. I am executing these queries in a remote informix db server.The data got as a result of executing sql1.sql and sql2.sql is got in file1.dat and file2.dat respectively. cmd= ssh "$USER_NAME"@"$HOST_NAME" "export... (0 Replies)
Discussion started by: Shri123
0 Replies

5. Shell Programming and Scripting

Reading from a CSV and writing in same CSV file

Hi, I am tryng to read from a csv file and based on some grep command output I will modify one of the column in the same csv. Example:- Input CSV:- 20120829001415,noneAA,google.com 20120829001415,dfsafds,google.com 20120829001415,noneAA,google.com Intermediate Step:- If 2nd column of... (3 Replies)
Discussion started by: kmajumder
3 Replies

6. Shell Programming and Scripting

Executing set of sql queries from shell script

Hi All, I tried executing set of queries from shell script but not able to capture the input query in the log file. The code looks something similar to below sqlplus user/pwd@dbname << EOF > output.log $(<inputfile.txt) EOF The above code is capturing the output of queries into... (9 Replies)
Discussion started by: loggedin.ksh
9 Replies

7. Shell Programming and Scripting

Executing Multiple Queries in parallel in Shell

I have n number of SQL queries needs to executed in Shell. Result of this query need to assign in a variable. Once all the queries are executed script needs to exit. Sample Query: SQL 1: Select Count(*) from TABLE GROUP BY COL1,COL2 SQL 2: Select Count(*) from TABLE GROUP BY COL1,COL2 ... (2 Replies)
Discussion started by: Niranjancse
2 Replies

8. Shell Programming and Scripting

Creating a Continuous File Reading-Executing Shell Script

I need to write something that will read and execute all the files(Mainly executable scripts) inside one or more folders; in other words, a continuous chain with a break when finished. I'm new to shell and need syntax help. I'm on Ubuntu 12.10-Gnome btw. Here are some main highlights I think... (2 Replies)
Discussion started by: linuxlololol
2 Replies

9. Shell Programming and Scripting

Issue on executing db2 queries through shell script

hi i am trying to execute db2 queries through shell script. it's working fine but for few queries is not working ( those queries are taking time so the script is not waiting to get the complete the execution of that query ) could you please any one help me on this is there any wait... (1 Reply)
Discussion started by: bhaskar v
1 Replies

10. Shell Programming and Scripting

Reading CSV file

Hi experts, Im having csv file with few columns which should contain data as shown below. Want to check if column 3 contain row with duplicate value(9876,9876) then corresponding to this in col2 should contain text "tax" and should not contain text "non". Word "non" can come but if in column3... (2 Replies)
Discussion started by: as7951
2 Replies
PHISTO(1)						      General Commands Manual							 PHISTO(1)

NAME
phisto - compute a luminance histogram from one or more RADIANCE pictures SYNOPSIS
phisto picture .. DESCRIPTION
Phisto is a script that calls pfilt(1), rcalc(1) and histo(1) to compute a histogram of log luminance values for foveal samples in the given picture files. A foveal sample covers approximately 1 degree, though this script does not use this exact area. The minimum and max- imum values are determined, and 100 histogram bins are uniformly divided between these extrema. Foveal samples less than 1e-7 cande- las/sq.meter are silently ignored. If no picture is named on the command line, the standard input is read. The primary function of this script is to precompute histograms for the pcond(1) program, which may then be used to compute multiple, iden- tical exposures. This is especially useful for animations and image comparisons. EXAMPLE
To compute two identical tone mappings for image1.hdr and image2.hdr: phisto image1.hdr image2.hdr > both.histo pcond -I -h image1.hdr < both.histo > image1m.hdr pcond -I -h image2.hdr < both.histo > image2m.hdr AUTHOR
Greg Ward Larson SEE ALSO
histo(1), pcond(1), pfilt(1), pvalue(1), rcalc(1), total(1) RADIANCE
3/12/98 PHISTO(1)
All times are GMT -4. The time now is 10:29 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy