Output is not Accurate


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Output is not Accurate
# 1  
Old 10-17-2013
Awk Output is not Accurate

list db directory |grep alias |awk '{print "connect to ",$4}'

In a shell script the below line should display output as below

connect to <DATABASENAME>

but its throwing error like


Code:
 
 Syntax Error The source line is 1.
 The error context is
                {print connect to, >>>  } <<<
 awk: 0602-502 The statement cannot be correctly parsed. The source line is 1.

Can somebody help to rectify this ? Is there any syntax error ?

Last edited by rocking77; 10-17-2013 at 10:39 AM..
# 2  
Old 10-17-2013
It looks good interms of grep & awk. What does "list db directory " ?

Small suggestion,
Code:
list db directory |awk '/alias/ {print "connect to ",$4}'

instead of
Code:
list db directory |grep alias |awk '{print "connect to ",$4}'

# 3  
Old 10-17-2013
Out put of list db directory will come like this for n no.of database entries.



Code:
 
Database 1 entry:
 Database alias                       = XXXXX
 Database name                        = XXXXX


Tested ur code seperatly not with script ..Its showing o/p properly.

Code:
 
 list db directory |awk '/alias/ {print "connect to ",$4}'
connect to  AAAAAA
connect to  BBBBB
connect to  CCCCCC
connect to  DDDDD

But when add the same line to my script and ran its throwing the same error which pasted initially.
# 4  
Old 10-17-2013
I am not sure.

Code:
 awk '/alias/ {print "connect to",$4}' INPUT

output:
Code:
connect to XXXXX

Code:
cat INPUT
Database 1 entry:
 Database alias                       = XXXXX
 Database name                        = XXXXX

# 5  
Old 10-17-2013
You have truncated the script as well as the input. Please post more context.
# 6  
Old 10-17-2013
Syntax error using Awk

Below is hte script which i m trying to for my requirement.If we run the highlighted part individually on database its running file and production accurate o/p
Expected

connect to XXXX
connect to YYYY
connect to ZZZ.




Code:
for line in `cat 1.txt`
do
echo @@@@@@@ YOU ARE IN HOST ${line} @@@@@@@@@ >> CRON-List
ssh -o ConnectTimeout=10 ${line} "ls '/home/prods/db2' |grep "^U"|sort|uniq" > I-List
    for line1 in `cat I-List`
     do
 typeset -l line1
instance=$line1
     ssh -o ConnectTimeout=10 ${line} "ksh -s <<EOF
       sudo suudb $instance
echo  $instance;>>file.out
db2 list db directory |grep alias |awk '{print "connect to " $4}'>>file.tmp"
done

# 7  
Old 10-17-2013
That's what I thought: an unmatched double quote in front of ksh -s <<EOF and/or a missing EOF token.
Login or Register to Ask a Question

Previous Thread | Next Thread

8 More Discussions You Might Find Interesting

1. AIX

AIX dump device not showing accurate size

I am trying to configure dump devices on my AIX server. Running 7100-03-04-1441. My dump device needs to be about 2GB in size. My PP Size is 1024MB, so I create the device with 2 PPs. When I run lslv on the dump device, it shows the 2 PPs, and a PP Size of 1024 megabytes. However, a dumpcheck... (4 Replies)
Discussion started by: paqman
4 Replies

2. UNIX for Beginners Questions & Answers

Listing files from October 4th is not accurate

Good evening: Need your help please Before deleting older logs from octobre 4th i need to identify which files i have to remove, for instance today is octobre 8ht, i need to remove files from October 4th Because there are many files i can not list because error args too long, so ... (5 Replies)
Discussion started by: alexcol
5 Replies

3. Shell Programming and Scripting

Facing problem while printing accurate decimal value

Hi, I have a file tp.txt having below data CE2DD,N,5055,16.12.2013,3.114,12195.89,MVR,003388,Web::00000005055,Web Payment and i am using below code to print the values for var_amt_pay in `awk -F',' '{ arr += $6} END {for (i in arr) {print i "," arr } }' tp.txt` do ... (2 Replies)
Discussion started by: ranabhavish
2 Replies

4. Hardware

time accurate simulator

Hi all, Does anybody know how to build a cycle accurate simulator? I've looked at QEMU and SESC simulator, but they are only cycle accurate for the CPU part. I'm looking for a simulator which can estimate the performance including CPU and I/O. For example, when I configure the simulator by SSD... (2 Replies)
Discussion started by: qqkk88
2 Replies

5. Shell Programming and Scripting

Shell Script not showing accurate Time Stamp and Size

Hey guys - I have made this script and for some reason, I dont see time stamp as "Month-Day-YYYY Hours-Mins" - all i see is Month and Day. Also, my file size is approximated. For example, if the size is 19,606KB - the script shows as 20M. Is there a way to see the exact file size? How do i... (2 Replies)
Discussion started by: DallasT
2 Replies

6. UNIX for Advanced & Expert Users

Retrieving accurate file timestamp

Hi Gurus, The requirement is to collect the timestamp of soft links and collect it in a file in the following pattern: This is the expected output: Pattern: MM/DD/YYYY hh:mi:ss filename Example: 12/26/2008 10:31:09 <Filename>.zip The closest way I could get was this: ls... (8 Replies)
Discussion started by: jidsh
8 Replies

7. UNIX for Dummies Questions & Answers

Calculation - Result not accurate if numbe too big

Dear all, Below is my script, totalCount=57006427 totalSummCount=1207590 let percentageSumTmp1=${totalCount}-${totalSummCount} let percentageSumTmp2=${percentageSumTmp1}*100 The expected result for percentageSumTmp2 should be (5579883700), but when I execute the script in unix env i... (3 Replies)
Discussion started by: epall
3 Replies

8. Solaris

How accurate is the HCL for Solaris 10?

I have a Sun Ultra 5 that is running Solaris 8. I believe I meet the minimum requirements for Solaris 10 but the Ultra 5 is not on the HCL. This will be my first ever Solaris upgrade so do I follow the HCL guidelines? TiA (4 Replies)
Discussion started by: PapaPark
4 Replies
Login or Register to Ask a Question