Unable to print block of data


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Unable to print block of data
# 1  
Old 01-17-2014
Unable to print block of data

Hi All,

Iam unable to print the below block and getting the error.Can anyone please help me in this.
Code:
 Input Data
eaits001z$ echo "-------LINENO_JOBID_VAL--------${LINENO_JOBID_VAL}---"
-------LINENO_JOBID_VAL--------58167|253473 58169|253473 58171|253473 58179|253473 58180|253473 58181|257311 58183|257311 58185|257311 58187|257311 58192|257311 58196|263935 58198|263935 58200|263935 58202|263935 58207|263935 58211|264359 58212|264360 58215|264360 58217|264360 58219|264360 58227|264360 58229|264360 58230|264487 58231|264488 58234|264488 58236|264488 58238|264488 58246|264488 58248|264488 58249|286343 58251|286343 58253|286343 58255|286343 58260|286343 58264|286469 58266|286469 58268|286469 58270|286469 58275|286469 58279|287226 58281|287226 58283|287226 58285|287226 58290|287226 58294|287351 58296|287351 58298|287351 58300|287351 58305|287351 58309|292485 58311|292485 58313|292485 58315|292485 58320|292485 58324|292754 58326|292754 58328|292754 58330|292754 58335|292754 58339|293116 58341|293116 58343|293116 58345|293116 58350|293116 58354|293150 58356|293150 58358|293150 58360|293150 58365|293150 58369|293207 58371|293207 58373|293207 58375|293207 58380|293207 58384|293241 58386|293241 58388|293241 58390|293241 58395|293241 58399|293486 58401|293486 58403|293486 58405|293486 58410|293486 58414|293501 58416|293501 58418|293501 58420|293501 58425|293501 58429|293521 58431|293521 58433|293521 58435|293521 58440|293521 58444|298297 58446|298297 58448|298297 58450|298297 58455|298297 58459|299130 58461|299130 58463|299130 58465|299130 58470|299130 58474|299428 58476|299428 58478|299428 58480|299428 58485|299428 58489|304171 58491|304171 58493|304171 58495|304171 58500|304171 58504|306320 58506|306320 58508|306320 58510|306320 58515|306320 58519|321170 58521|321170 58523|321170 58525|321170 58530|321170 58534|329122 58536|329122---

Script
for (i=0;i<${#LINENO_JOBID_VAL[@]};i++)
do
      STARTPT=`echo ${LINENO_JOBID_VAL[$i]}|cut -d"|" -f1`
   ENDPT=`echo ${LINENO_JOBID_VAL[$i]}|cut -d"|" -f2`
   if [ ${STARTPT} != "" ] && [ ${ENDPT} == "EOF" ]
   then
     echo "IN SUCCESS CONDITION--"$STARTPT
     nawk -v STPT=$STARTPT 'NR >= STPT { print $0} ' ${BASEPATH}/$FILE|nawk '{ if (match($0,"^[0-9][0-9][0-9][0-9] [A-Z][a-z][a-z] [0-9][0-9]")){ if ($0 !~ /Job-'$MAX_JOB'/) {exit; }else {  print $0; }} print $0}' 
   else
     echo "IN FAILED CONDITION--"$STARTPT"|"$ENDPT
     nawk -v STPT=$STARTPT EDPT=$ENDPT 'NR==STPT,NR==EDPT { print $0} ' ${BASEPATH}/$FILE 
   fi
done

# 2  
Old 01-17-2014
What is your aim ? what's error message ?
# 3  
Old 01-17-2014
Hi, Sorry for not being clear. I want to make a dynamic loop for the values in "LINENO_JOBID_VAL" using space as delimiter and the separate the field 1(start point) and field 2 (end point) and do the printing logic. I tried with referring some older posts but it is not helping and when I include the below piece in my shell iam getting the below error. Hence not sure how I make a dynamic loop and use it as array.
Code:
test.sh: syntax error at line 140: `(' unexpected

which is the for loop in our case..
FYI..Iam using solaris 10 box.
# 4  
Old 01-17-2014
Quote:
Originally Posted by cskumar
Hi All,

Iam unable to print the below block and getting the error.Can anyone please help me in this.
Code:
 
Script
for (i=0;i<${#LINENO_JOBID_VAL[@]};i++)
do
      STARTPT=`echo ${LINENO_JOBID_VAL[$i]}|cut -d"|" -f1`
   ENDPT=`echo ${LINENO_JOBID_VAL[$i]}|cut -d"|" -f2`
   if [ ${STARTPT} != "" ] && [ ${ENDPT} == "EOF" ]
   then
     echo "IN SUCCESS CONDITION--"$STARTPT
     nawk -v STPT=$STARTPT 'NR >= STPT { print $0} ' ${BASEPATH}/$FILE|nawk '{ if (match($0,"^[0-9][0-9][0-9][0-9] [A-Z][a-z][a-z] [0-9][0-9]")){ if ($0 !~ /Job-'$MAX_JOB'/) {exit; }else {  print $0; }} print $0}' 
   else
     echo "IN FAILED CONDITION--"$STARTPT"|"$ENDPT
     nawk -v STPT=$STARTPT EDPT=$ENDPT 'NR==STPT,NR==EDPT { print $0} ' ${BASEPATH}/$FILE 
   fi
done

correct like this, and try
Code:
for(( i=0; i<${#LINENO_JOBID_VAL[@]}; i++ ))

# 5  
Old 01-17-2014
Not working in Shell

Hi Akshay,

Thanks for the suggestion.However it worked when I ran separately..But when I use the same piece of code in shell.It's not working and getting the same error as above
Code:
test.sh: syntax error at line 140: `(' unexpected

No clue why iam getting it..

FYI. Iam using the bash mode.

Regards,
Kumar

Last edited by cskumar; 01-17-2014 at 01:46 PM..
# 6  
Old 01-17-2014
Quote:
Originally Posted by cskumar
Hi Akshay,

Thanks for the suggestion.However it worked when I ran separately..But when I use the same piece of code in shell.It's not working and getting the same error as above
[CODE]test.sh: syntax error at line 140: `(' unexpected[/CODE]No clue why iam getting it..

FYI. Iam using the bash mode.

Regards,
Kumar
show your code, I can't see what's there in 140th line
# 7  
Old 01-21-2014
Inout,source code and Error

Hi Akshay,

Please use the below input to simulate the issue.

Code:
Input
------------------
2014 Jan 14 15:12:43:460 GMT +0 BW.Folder-Process_Archive Debug [BW-User] RequestMessage Job-329121 [Services/Peoplesoft/AcV_Add/Interface/SourceRequest.process/Activate/LogEntry]: <ActivityOutput><sendSubject>TEST.GT.TTT.PS.Request._Null_.asasasa.1</sendSubject><replySubject>_INBOX.C0A8F848.24CE52D3CE5F15FB9E0.1</replySubject><certifiedSequenceNumber>0</certifiedSequenceNumber><body><ns0:field xmlns:ns0="http://xmlns.tibco.com/2003/5/bw/plugins/tibrv"><ns0:name>^pfmt^</ns0:name><ns0:id>0</ns0:id><ns0:simple xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xs="http://www.w3.org/2001/XMLSchema" xsi:type="xs:int">10</ns0:simple></ns0:field><ns0:field xmlns:ns0="http://xmlns.tibco.com/2003/5/bw/plugins/tibrv"><ns0:name>^ver^</ns0:name><ns0:id>0</ns0:id><ns0:simple xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xs="http://www.w3.org/2001/XMLSchema" xsi:type="xs:int">30</ns0:simple></ns0:field><ns0:field xmlns:ns0="http://xmlns.tibco.com/2003/5/bw/plugins/tibrv"><ns0:name>^type^</ns0:name><ns0:id>0</ns0:id><ns0:simple xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xs="http://www.w3.org/2001/XMLSchema" xsi:type="xs:int">1</ns0:simple></ns0:field><ns0:field xmlns:ns0="http://xmlns.tibco.com/2003/5/bw/plugins/tibrv"><ns0:name>^encoding^</ns0:name><ns0:id>0</ns0:id><ns0:simple xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xs="http://www.w3.org/2001/XMLSchema" xsi:type="xs:int">1</ns0:simple></ns0:field><ns0:field xmlns:ns0="http://xmlns.tibco.com/2003/5/bw/plugins/tibrv"><ns0:name>^tracking^</ns0:name><ns0:id>0</ns0:id><ns0:msg><ns0:field><ns0:name>^id^</ns0:name><ns0:id>0</ns0:id><ns0:simple xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xs="http://www.w3.org/2001/XMLSchema"
ttttttttttttttttttttttttttttttttttasasaaaaaaaaaaaaaaaaaaaaa
asaaaaaaaaaaaaaaaaaaaaaaaaa
bbbbbbbbdsdsdsdsdsdssssssssssssssssssssssssssssssssd
2014 Jan 14 15:12:43:460 GMT +0 BW.Folder-Process_Archive Debug [BW-User] RequestMessage Job-329122 [Services/Peoplesoft/AcV_Add/Interface/SourceRequest.process/Activate/LogEntry]: <ActivityOutput><sendSubject>TEST.GT.TTT.PS.Request._Null_.asasasa.1</sendSubject><replySubject>_INBOX.C0A8F848.24CE52D3CE5F15FB9E0.1</replySubject><certifiedSequenceNumber>0</certifiedSequenceNumber><body><ns0:field xmlns:ns0="http://xmlns.tibco.com/2003/5/bw/plugins/tibrv"><ns0:name>^pfmt^</ns0:name><ns0:id>0</ns0:id><ns0:simple xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xs="http://www.w3.org/2001/XMLSchema" xsi:type="xs:int">10</ns0:simple></ns0:field><ns0:field xmlns:ns0="http://xmlns.tibco.com/2003/5/bw/plugins/tibrv"><ns0:name>^ver^</ns0:name><ns0:id>0</ns0:id><ns0:simple xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xs="http://www.w3.org/2001/XMLSchema" xsi:type="xs:int">30</ns0:simple></ns0:field><ns0:field xmlns:ns0="http://xmlns.tibco.com/2003/5/bw/plugins/tibrv"><ns0:name>^type^</ns0:name><ns0:id>0</ns0:id><ns0:simple xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xs="http://www.w3.org/2001/XMLSchema" xsi:type="xs:int">1</ns0:simple></ns0:field><ns0:field xmlns:ns0="http://xmlns.tibco.com/2003/5/bw/plugins/tibrv"><ns0:name>^encoding^</ns0:name><ns0:id>0</ns0:id><ns0:simple xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xs="http://www.w3.org/2001/XMLSchema" xsi:type="xs:int">1</ns0:simple></ns0:field><ns0:field xmlns:ns0="http://xmlns.tibco.com/2003/5/bw/plugins/tibrv"><ns0:name>^tracking^</ns0:name><ns0:id>0</ns0:id><ns0:msg><ns0:field><ns0:name>^id^</ns0:name><ns0:id>0</ns0:id><ns0:simple xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xs="http://www.w3.org/2001/XMLSchema"
asasssssssssssssssssssssasasasa
asaaaaaaaaaaaaaaaaaaa

Code:
#!/bin/bash

BASEPATH="/opt/tibco/logs/bw/EAI_Automation"

FILE="Input.log"
echo "File name::${FILE}" 

STARTPT_ENDPT_VAL="5|EOF"

echo "-------STARTPT_ENDPT_VAL--------${STARTPT_ENDPT_VAL}---"

########################################################
#Printing The Final set using different awk methods
########################################################

for(( i=0; i<${#STARTPT_ENDPT_VAL[@]}; i++ ))
do
      STARTPT=`echo ${STARTPT_ENDPT_VAL[$i]}|cut -d"|" -f1`
   ENDPT=`echo ${STARTPT_ENDPT_VAL[$i]}|cut -d"|" -f2`
   if [ ${STARTPT} != "" ] && [ ${ENDPT} == "EOF" ]
   then
     echo "IN SUCCESS CONDITION--"$STARTPT
     nawk -v STPT=$STARTPT 'NR >= STPT { print $0} ' ${BASEPATH}/$FILE 
   else
     echo "IN FAILED CONDITION--"$STARTPT"|"$ENDPT
     nawk 'NR=='${STARTPT}',NR=='${ENDPT}' { print "$0} ' ${BASEPATH}/${FILE}
   fi
done

echo "###############################Print Ends###############################################"
done

Code:
Error log
------------------------
bsss001z$ sh test_script.sh
File name::Input.log
***********MAXIMUM JOBID**********329122
-------STARTPT_ENDPT_VAL--------5|EOF---
test_script.sh: syntax error at line 16: `(' unexpected

Code:
Expected Output--If we run the commands separately
---------------------------------------------------------------------------
IN SUCCESS CONDITION--5
2014 Jan 14 15:12:43:460 GMT +0 BW.Folder-Process_Archive Debug [BW-User] RequestMessage Job-329122 [Services/Peoplesoft/AcV_Add/Interface/SourceRequest.process/Activate/LogEntry]: <ActivityOutput><sendSubject>TEST.GT.TTT.PS.Request._Null_.asasasa.1</sendSubject><replySubject>_INBOX.C0A8F848.24CE52D3CE5F15FB9E0.1</replySubject><certifiedSequenceNumber>0</certifiedSequenceNumber><body><ns0:field xmlns:ns0="http://xmlns.tibco.com/2003/5/bw/plugins/tibrv"><ns0:name>^pfmt^</ns0:name><ns0:id>0</ns0:id><ns0:simple xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xs="http://www.w3.org/2001/XMLSchema" xsi:type="xs:int">10</ns0:simple></ns0:field><ns0:field xmlns:ns0="http://xmlns.tibco.com/2003/5/bw/plugins/tibrv"><ns0:name>^ver^</ns0:name><ns0:id>0</ns0:id><ns0:simple xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xs="http://www.w3.org/2001/XMLSchema" xsi:type="xs:int">30</ns0:simple></ns0:field><ns0:field xmlns:ns0="http://xmlns.tibco.com/2003/5/bw/plugins/tibrv"><ns0:name>^type^</ns0:name><ns0:id>0</ns0:id><ns0:simple xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xs="http://www.w3.org/2001/XMLSchema" xsi:type="xs:int">1</ns0:simple></ns0:field><ns0:field xmlns:ns0="http://xmlns.tibco.com/2003/5/bw/plugins/tibrv"><ns0:name>^encoding^</ns0:name><ns0:id>0</ns0:id><ns0:simple xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xs="http://www.w3.org/2001/XMLSchema" xsi:type="xs:int">1</ns0:simple></ns0:field><ns0:field xmlns:ns0="http://xmlns.tibco.com/2003/5/bw/plugins/tibrv"><ns0:name>^tracking^</ns0:name><ns0:id>0</ns0:id><ns0:msg><ns0:field><ns0:name>^id^</ns0:name><ns0:id>0</ns0:id><ns0:simple xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xs="http://www.w3.org/2001/XMLSchema"
asasssssssssssssssssssssasasasa
asaaaaaaaaaaaaaaaaaaa

---------- Post updated 01-21-14 at 06:24 AM ---------- Previous update was 01-20-14 at 12:47 PM ----------

Hi, Can anyone help me for the above issue since I got struck at the last step and need your assistance please.

Regards,
Kumar.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Unable to print python array in shell script loop.

I am unable to loop print a python string array in my unix shell script: ~/readarr.sh '{{ myarr }}' more readarr.sh echo "Parameter 1:"$1 MYARRAY= $1 IFS= MYARRAY=`python <<< "print ' '.join($MYARRAY)"` for a in "$MYARRAY"; do echo "Printing Array: $a" done Can you... (10 Replies)
Discussion started by: mohtashims
10 Replies

2. Shell Programming and Scripting

Unable to retrieve data from shell when connected to Oracle

I am trying to get the data from oracle table to a variable I have tried the below code #/usr/bin/sh echo " I am in correct loop" SPOOL_FILE=/app/scripts/alt.lst sqlplus /nolog <<END_SQL connect bindu/bindu@gis whenever sqlerror exit failure rollback;... (4 Replies)
Discussion started by: Kiransagar
4 Replies

3. Shell Programming and Scripting

Unable to print dynamic arguments in for loop

Hi All, I want to pass few dynamic arguments to shell script. The number of arguments differ each time I call the script. I want to print the arguments using the for loop as below. But not working out. for (( i=1; i<=$#; i++ )) do echo $"($i)" done /bin/sh test.sh arg1 arg2 arg3 ... (1 Reply)
Discussion started by: laalesh
1 Replies

4. Shell Programming and Scripting

Unable to Print Count

Hi All, I am performing addition of two inetger variables which assigning output to a new variable getting following error. Check1.sh #!/bin/ksh filesrc=/usr/kk/Source1.txt filetgt=/usr/kk/Source2.txt FINAL_COUNTS= `awk '{n++} END {printf "%012d\n",n}' ${filesrc} ${filetgt}`... (3 Replies)
Discussion started by: kmsekhar
3 Replies

5. Shell Programming and Scripting

FNR>2 is not working and unable to extract data from a file

Hi, I have a file in windows environment and moved to UNIX through FTP (ASCII format). The file is having with tab delimited file. awk ‘FNR>2' file_cust*.txt >>filnal.txt I have the same file in production; it is working fine with the same procedure. Once we receive the file in windows... (1 Reply)
Discussion started by: onesuri
1 Replies

6. Programming

Unable to publish data

Hi All, In my application, we are using Publish/subscribe model implemented in JAVA and when I implemented it on windows to windows os,it is working fine and able to publish the right data and even when I am trying the same between two different OS i.e between Windows and Solaris sparc or... (1 Reply)
Discussion started by: smartgupta
1 Replies

7. Solaris

NIS slave unable to copy the data bases

Hi, I'm learning for my Solaris 10 sys-admin part 2. I'm now trying to get nis working because for the exercise. I run in to a problem. Setup: Three Systems solaris101 (client) Nothing wrong here havent made any config changes yet. solaris102 (master server) Interfaces ... (1 Reply)
Discussion started by: jld
1 Replies

8. Shell Programming and Scripting

Unable to set a data to array

Hi All, Iam trying to set the value to the array... Still its not happening Following is the code: #!/usr/bin/ksh filenames="x"; filenames="y"; echo $filenames; echo $filenames; O/P: x x Iam expecting (2 Replies)
Discussion started by: kiranlalka
2 Replies

9. AIX

Unable to print Cyrillic fonts

Hi All I confifured HP 4250 printer on AIX server..I am unable to print cyrillic fonts prints. Please assist.. (0 Replies)
Discussion started by: kandatihari
0 Replies

10. SCO

Non-Root Users Unable to Print

UnixWare 7, Release 7.1.3 We have a customer that has frequent issues with Non-Root users being unable to print. They are able to print w/o issues, but all of the sudden it stops working. The only workaround we have at this point is to reboot the server. It is happening weekly according to... (1 Reply)
Discussion started by: cfshd
1 Replies
Login or Register to Ask a Question