Not able to get result to unix variables


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Not able to get result to unix variables
# 1  
Old 02-15-2010
Not able to get result to unix variables

I am trying to get the Srcreccnt and Tgtreccnt from unix files and update the oracle table.

But i get the below error:
Code:
ERROR at line 1:
ORA-00936: missing expression
 
update velocity_process_control set SOURCE_RECORD_COUNT=,SOURCE_RECORD_COUNT= where batch_id=
*
ERROR at line 1:
ORA-00936: missing expression

Can you help me where i doing wrong in capturin the values into unix variables and passing to Oracle.
Code:
Srcreccnt=cat `ls ${SOURCE_DIR}/ATRPU_RP_ATU_*.csv | head -1`|wc-l
Tgtreccnt=cat `ls ${IMF_TARGET_DIR}/IMF_ATRPU_*.csv | tail -1`|wc-l
echo "Source record count is ${Srcreccnt}"
echo "Source record count is ${Tgtreccnt}"
sqlplus -S core/core@cptest <<EOF
set feedback off
set head off
update velocity_process_control set SOURCE_RECORD_COUNT=${Srcreccnt},SOURCE_RECORD_COUNT=${Tgtreccnt} where batch_id=
(select batch_id from velocity_process_control
minus
select batch_id from velocity_process_control
where rownum < (select count(*) from velocity_process_control))
;
/
EOF

please don't reformat text like that. Thank you

Last edited by jim mcnamara; 02-15-2010 at 03:54 PM.. Reason: reformat to readable
# 2  
Old 02-15-2010
I noticed you are using:
Code:
wc-l

instead of:
Code:
wc -l

# 3  
Old 02-15-2010
First I saw this "mistake"

Code:
Srcreccnt=`cat ls ${SOURCE_DIR}/ATRPU_RP_ATU_*.csv | head -1 |wc -l`
Tgtreccnt=`cat ls ${IMF_TARGET_DIR}/IMF_ATRPU_*.csv | tail -1 |wc -l`

the characters ` enclosing the sentence

But now I'm confused, because when you use tail and head you only display 1 line, and wc always will result in 1. Is this ok? Can you explain a little bit more?
# 4  
Old 02-15-2010
can you explain what are you trying to extract from these commands... because it won't make any sense...
Quote:
Srcreccnt=cat `ls ${SOURCE_DIR}/ATRPU_RP_ATU_*.csv | head -1`|wc-l
Tgtreccnt=cat `ls ${IMF_TARGET_DIR}/IMF_ATRPU_*.csv | tail -1`|wc-l
# 5  
Old 02-15-2010
It seems to me he is counting the number of lines in the first file returned by the ls commands.
# 6  
Old 02-15-2010
The commands seem pretty strange to me.

Variable equals word "cat" plus line count of head count 1 of listing of files... i.e. 1.
# 7  
Old 02-15-2010
HI All

My Requirement is

I have source file directory and Target file directory.

1. From the list of files in source file directory, From the first file i should get the count of records.
2. From the list of target files in target directory, I should find recent processed file. and get the count of records in the file

so i should update src count and target count to oracle table.

Am i doing any blunders ?.

Please help me as i am new to unix.

Thanks all,
vsmeruga

---------- Post updated at 04:19 PM ---------- Previous update was at 03:39 PM ----------

So friends,

Can i use the below list of cmds to get my results:

Code:
Srcreccnt=cat `ls ${SOURCE_DIR}/ATRPU_RP_ATU_*.csv | head -1`|wc-l
Tgtreccnt=cat `ls ${IMF_TARGET_DIR}/IMF_ATRPU_*.csv | tail -1`|wc-l

or

Code:
Srcreccnt=`cat ls ${SOURCE_DIR}/ATRPU_RP_ATU_*.csv | head -1 |wc -l`
Tgtreccnt=`cat ls ${IMF_TARGET_DIR}/IMF_ATRPU_*.csv | tail -1 |wc -l`

Please confirm..
Thanks,
vsmeruga

Last edited by Franklin52; 02-16-2010 at 04:53 AM.. Reason: Please use code tags!
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX and Linux Applications

Passing variables from UNIX to Ansible to UNIX shell

I m passing a variable stringg from Unix shell which has value 'Good Day' to ansible and from ansible to a second shell script where it print only Good instead of 'Good Day' passing the variable stringg from unix shell script1.sh echo $stringg ansible-playbook install.yml -i... (1 Reply)
Discussion started by: mohtashims
1 Replies

2. Shell Programming and Scripting

How to compare the current result with previous line result.?

Hi Gurus, I have requirement to compare current result with previous reuslt. The sample case is below. 1 job1 1 1 job2 2 1 job3 3 2 job_a1 1 2 job_a2 2 2 job_a3 3 3 job_b1 1 3 job_b2 2 for above sample file, GID is group ID, for input line, the job run... (1 Reply)
Discussion started by: ken6503
1 Replies

3. UNIX for Advanced & Expert Users

How to export Result to Excel Tabular format from UNIX?

Hi I am working on a script in which I am firing a query on database through Unix and getting the result set. I want to export that in an excel file. I am able to do so nut the result are exported horizontally one below the other. Can anyone plss help me out in exporting the Result in Tabular... (4 Replies)
Discussion started by: Saritau3
4 Replies

4. Shell Programming and Scripting

assinging the printf result to variables

Getting the below error while executing this. Able to run the below commands Individually. #!/bin/bash a=$(printf "%d\n" 0x01E); b=$(printf "%d\n" 0x01A); echo $a echo $b c=`expr $a - $b` echo $c syntax error at line 2: `a=$' unexpected (2 Replies)
Discussion started by: sai_1712
2 Replies

5. Shell Programming and Scripting

Variables in unix

Hi, I have defined 2 variables in a ksh file something like below. x=abc y=x Now, I want to get abc printed using y. I have tried echo $"$y" and I am getting $x but where as I am expecting abc. Please suggest. (something like pointer pointer in C language) (2 Replies)
Discussion started by: ravinunna
2 Replies

6. UNIX for Dummies Questions & Answers

UNIX newbie with a really odd result!

I am relatively new to UNIX and am having some really weird results with redirecting output. I will start at the beginning. I have a file with consists of a list of a chemical name followed by a tab and then a string of characters known as a SMILE string in this format PS_1 C=C PS_2 ... (4 Replies)
Discussion started by: Osito22es
4 Replies

7. UNIX for Dummies Questions & Answers

Script giving different result on Linux compared to Unix

Hi I have a script executing fine in Unix but in linux I am getting different result. I have three files under /local/home/temp/Gen test.sh list.txt shst.txt Contents of test.sh -------------------------- #!/bin/ksh K=0; SCRIPT_DIR=/local/home/temp/Gen cat... (2 Replies)
Discussion started by: malavm
2 Replies

8. UNIX for Dummies Questions & Answers

display the result of wc -l with words before and after the result

hello showrev -p | wc -l returns: 381 What to do in case I want to have this output: number of lines returned by showrev -p is: 381 thx (3 Replies)
Discussion started by: melanie_pfefer
3 Replies

9. Shell Programming and Scripting

Outputting formatted Result log file from old 30000 lines result log<help required>

Well I have a 3000 lines result log file that contains all the machine data when it does the testing... It has 3 different section that i am intrsted in 1) starting with "20071126 11:11:11 Machine Header 1" 1000 lines... "End machine header 1" 2) starting with "20071126 12:12:12 Machine... (5 Replies)
Discussion started by: vikas.iet
5 Replies

10. Shell Programming and Scripting

how to retrieve sql result to unix....

Hi, i would like to retrieve seql result and write it into unix text file like "result.txt" In unix, normally, I type "sql" and get into sql,then type "select....." to run and get the result....then copy and paste into result.txt any possible way to write a script to run it automatically?... (3 Replies)
Discussion started by: happyv
3 Replies
Login or Register to Ask a Question