Problem with awk array when loading from shell variable

Hi, I have a problem with awk array when iam trying to use awk in solaris box as below..Iam unable to figure out the problem..
Need your help. is there any alternative to make it in arrays from variable values

nawk 'BEGIN {SUBSEP=" ";
split("101880|110045 101887|110045 101896|110045 101903|110045 101910|110045 101919|110045 101926|110045 101933|110045 101941|110045 101948|110045 101957|110046 101966|110045 101975|110046 101992|110045 102002|110046 102009|110046 102016|110046 102024|110046 102033|110046 102048|110046 102063|110046 102078|110046 102093|110047 102103|110046 102112|110047 102128|110047 102137|110047 102144|110047 102151|110047 102160|110047 102168|110047",Val," ");
} 
END {
for (i in Val) print i,Val
}
' $FILE

O/p--Success

nawk 'BEGIN {SUBSEP=" ";
split('${LINENUMBER_JOBID}',Val," ");
} 
END {
for (i in Val) print i,Val
}
' $FILE

O/p Error:---
nawk: syntax error at source line 2
 context is
         >>> split(101880|110045 <<<
nawk: illegal statement at source line 2
        missing }
        missing )

Shell variable value:
-------------------

 echo "--${LINENUMBER_JOBID}==="--101880|110045
101887|110045
101896|110045
101903|110045
101910|110045
101919|110045
101926|110045
101933|110045
101941|110045
101948|110045
101957|110046
101966|110045
101975|110046
101992|110045
102002|110046
102009|110046
102016|110046
102024|110046
102033|110046
102048|110046
102063|110046
102078|110046
102093|110047
102103|110046
102112|110047
102128|110047
102137|110047
102144|110047
102151|110047
102160|110047
102168|110047===

The split looks ugly, it may be another way to divide your string.
What is your input file/data?

With 70 post you should also now how to use code tags

Yes, why don't you use code tags?

Looks like your shell variable has a <newline> char as a separator, to which awk responds with utter lack of comprehension.

Hi Jotne,Thanks for the info..will use code tags from here on.What iam trying to achieve is..I have the below blocks of data which i want to find the max Job-id and start printing only the blocks and omitting the rest
My logic goes in this way

> find the pattern [0-9]{4,} [A-Z][a-z]{2,} [0-9]{2,} i.,e 2013 Jan 23 09
and get the job-id and line number of the file
> Take it in a variable and find the max jobid in the file.
> Now traverse the jobid in the same variable and find the startpt and the endpt.
> send this to the basic awk command
awk 'NR==STPT,NR=={ENDPT}-1' and print only the blocks.

Here i got struck at the last point when i try to split the values through " ",take it in an array and send as startpoint and endpoint.
Need your help.
I/p

2013 Jan 23 09:12:02:716 IST +0 BW.TEST-2-Process_Archive Debug [BW-User] DEBUG Job-107544 [UtilityService
s/BWFLIB_Logging/BWFLIB_getLogger.process/GA_WL_LOGDEBUG]: Wed, Jan 23, 2013, 09:12:02 698[1111732318]::
LogMessage::CallSYs1AndSystem2SubProcess:: CallSystem1AndSystem2
TrackingInfo:: System2ServicevCustomerRequest-382_1358932322623
CustomId:: 192.168.248.250:6961937c:13a2b960ad6:-7ffd

2013 Jan 23 09:12:02:746 IST +0 BW.TEST-2-Process_Archive Debug [BW-User] DEBUG Job-107543 [UtilityService
Adapter.Request._Null_.vCustomer.1
ReplySubject:: _INBOX
2013 Jan 23 09:12:02:716 IST +0 BW.TEST-2-Process_Archive Debug [BW-User] DEBUG Job-107544 [UtilityService
s/BWFLIB_Logging/BWFLIB_getLogger.process/GA_WL_LOGDEBUG]: Wed, Jan 23, 2013, 09:12:02 698[1111732318]::
LogMessage::CallSYs1AndSystem2SubProcess:: CallSystem1AndSystem2
TrackingInfo:: System2ServicevCustomerRequest-382_1358932322623
CustomId:: 192.168.248.250:6961937c:13a2b960ad6:-7ffd

2013 Jan 23 09:12:02:746 IST +0 BW.TEST-2-Process_Archive Debug [BW-User] DEBUG Job-107544 [UtilityService
Adapter.Request._Null_.vCustomer.1
ReplySubject:: _INBOX

2013 Jan 23 09:12:02:716 IST +0 BW.TEST-2-Process_Archive Debug [BW-User] DEBUG Job-107543 [UtilityService
s/BWFLIB_Logging/BWFLIB_getLogger.process/GA_WL_LOGDEBUG]: Wed, Jan 23, 2013, 09:12:02 698[1111732318]::
LogMessage::CallSYs1AndSystem2SubProcess:: CallSystem1AndSystem2
TrackingInfo:: System2ServicevCustomerRequest-382_1358932322623
CustomId:: 192.168.248.250:6961937c:13a2b960ad6:-7ffd

---------- Post updated at 07:16 AM ---------- Previous update was at 07:07 AM ----------

Sorry i didnt mention the o/p..The expected o/p should be the blocks with Job-107544.

o/p

2013 Jan 23 09:12:02:716 IST +0 BW.TEST-2-Process_Archive Debug [BW-User] DEBUG Job-107544 [UtilityService
s/BWFLIB_Logging/BWFLIB_getLogger.process/GA_WL_LOGDEBUG]: Wed, Jan 23, 2013, 09:12:02 698[1111732318]::
LogMessage::CallSYs1AndSystem2SubProcess:: CallSystem1AndSystem2
TrackingInfo:: System2ServicevCustomerRequest-382_1358932322623
CustomId:: 192.168.248.250:6961937c:13a2b960ad6:-7ffd

2013 Jan 23 09:12:02:716 IST +0 BW.TEST-2-Process_Archive Debug [BW-User] DEBUG Job-107544 [UtilityService
s/BWFLIB_Logging/BWFLIB_getLogger.process/GA_WL_LOGDEBUG]: Wed, Jan 23, 2013, 09:12:02 698[1111732318]::
LogMessage::CallSYs1AndSystem2SubProcess:: CallSystem1AndSystem2
TrackingInfo:: System2ServicevCustomerRequest-382_1358932322623
CustomId:: 192.168.248.250:6961937c:13a2b960ad6:-7ffd

2013 Jan 23 09:12:02:746 IST +0 BW.TEST-2-Process_Archive Debug [BW-User] DEBUG Job-107544 [UtilityService
Adapter.Request._Null_.vCustomer.1
ReplySubject:: _INBOX

You are using code tags wrong. I am not able to read this.
Mark group of text, not all and select co-de button.
And you can use edit button to edit your post.

Again: did you check for the <newline> chars in your variable? Replace by space when creating it, and your split will fly!

@Jotne, I have done with editing part and @RudiC, will give a try as well..

Thanks,
cskumar.

---------- Post updated at 01:08 AM ---------- Previous update was at 12:46 AM ----------

@RudiC,
I have translated the "\n" to " ",but still not working..please see the below output..Still iam getting the same error.

eaits001z$ echo "-------LINENUMBER_JOBID--------${LINENUMBER_JOBID}---"
-------LINENUMBER_JOBID--------101880|110045 101887|110045 101896|110045 101903|110045 101910|110045 101919|110045 101926|110045 101933|110045 101941|110045 101948|110045 101957|110046 101966|110045 101975|110046 101992|110045 102002|110046 102009|110046 102016|110046 102024|110046 102033|110046 102048|110046 102063|110046 102078|110046 102093|110047 102103|110046 102112|110047 102128|110047 102137|110047 102144|110047 102151|110047 102160|110047 102168|110047 ---
eaits001z$ nawk -v LINENO=$LINENUMBER_JOBID 'BEGIN {SUBSEP=" ";
> split(LINENO,Val," ");
> }
> END {
> for (i in Val) print i,Val
> }
> ' $FILE

nawk: syntax error at source line 1
context is
>>> 101887|110045 <<<
nawk: bailing out at source line 1

Double quote the $LINENUMBER_JOBID.

I have almost made my script except the printing problem.Iam getting error in when i want to print between the start point and endpoint and more than start point.Can you please shed some light,,how can i overcome from this problem..

nawk -v JOBID=$MAX_JOB -v LINENO=$LINENUMBER_JOBID 'BEGIN {SUBSEP=",";START="N";
printem();
split(LINENO,Val,SUBSEP);
ARRLENGTH=split(LINENO,Val,SUBSEP);
print "ARRAY LENGTH***********"ARRLENGTH
}
function printem() {
    for (i in Val) { delete Val }
    for (i in a) { delete a }
}
{
for (i=1;i<=ARRLENGTH;i++)
{
  print "***********************LOOP*************************"i
  split(Val,a,"|");
  print "JOBID***********"JOBID
  print "Val["i"]::a[1]::a[2]***********"Val"::"a[1]"::"a[2]
  if (JOBID==a[2])
  {
     print "&&&&&&&&&MATCH FOUND&&&&&&&&&&"
     if (START=="N")
     {
        STARTPOINTER=a[1];START="Y";
        ENDPOINTER=STARTPOINTER;
        print "STARTING POINT************"STARTPOINTER
        print "ENDING POINT************"ENDPOINTER
     }
     if (a[1] > STARTPOINTER)
     {
       print "Only EndPointer needs to be changed**************"
       ((ENDPOINTER=a[1]-1))
       print "$$$$$$$$$$$$$$END POINT REACHED$$$$$$$$$$$$$$$"ENDPOINTER
     }
  }
  else
  {
     print "//////////////MATCH NOT FOUND////////////////"
     if (START=="Y" && a[1] > STARTPOINTER )
     {
       print "^^^^^^^^^^^^^STARTING POINT REACHED^^^^^^^^^^^"STARTPOINTER
       ((ENDPOINTER=a[1]-1))
       print "$$$$$$$$$$$$$$END POINT REACHED$$$$$$$$$$$$$$$"ENDPOINTER
       START="N";
NR==STARTPOINTER,NR==ENDPOINTER { print NR"|"$0}
      if (a[1] < STARTPOINTER)
     {
       print "Come out of the for loop**************"
       print "$$$$$$$$$$$$$$Block should be printed from starting point to EOF$$$$$$$$$$$$$$$"STARTPOINTER
NR>=STARTPOINTER { print NR"|"$0 }
       printem();exit;
     }
  }
}
}' $FILE

---------- Post updated at 06:53 AM ---------- Previous update was at 06:43 AM ----------

Please find the below expected output which i want to use it in the above script..

Expected O/p:
eaits001z$ nawk 'NR==102093,NR==102097 { print NR"|"$0} ' $FILE
102093|2013 Jan 23 09:12:02:716 IST +0 BW.TEST-2-Process_Archive Debug [BW-User] DEBUG Job-107544 [UtilityServices/BWFLIB_Logging/BWFLIB_getLogger.process/GA_WL_LOGDEBUG]: Wed, Jan 23, 2013, 09:12:02 698[1111732318]::
102094| LogMessage::CallSYs1AndSystem2SubProcess:: CallSystem1AndSystem2
102095| TrackingInfo:: System2ServicevCustomerRequest-382_1358932322623
102096| CustomId:: 192.168.248.250:6961937c:13a2b960ad6:-7ffd
102097|

Dear All,

Iam unable to use the print statement in the final stage of my awk..Any help would be much appreciated.

Thanks and Regards,
cskumar