Unable to print block of data


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Unable to print block of data
# 8  
Old 01-21-2014
Quote:
Originally Posted by cskumar
Hi Akshay,

Please use the below input to simulate the issue.

...
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

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

Regards,
Kumar.
done unexpected
# 9  
Old 01-22-2014
No impact with the Done statement

Hi Akshay,

I don't see any issue in the extra done statement and getting the same error.

regards,
Kumar.

---------- Post updated 01-22-14 at 04:55 AM ---------- Previous update was 01-21-14 at 08:32 AM ----------

Hi, Can anyone have a look at it and help me..Your immediate help will be appreciated.

Regards,
Kumar.

---------- Post updated at 12:11 PM ---------- Previous update was at 04:55 AM ----------

Hi All,

After the long struggle I got to know that the unexpected error is due to the bash version..

I have refer the old post and got the answer.

Looping through arrays | Unix Linux Forums | Shell Programming and Scripting

My next blocker is how to define the arrays using any delimiters..Kindly mind that the values are dynamic..
In the below example the space is the delimiter and I need the loop to run 4 times..But it is not working..Any clue will be highly appreciated.

Code:
VAR="5|EOF 89|840 45|454 45|454"
echo "***********VAR**********----${#VAR[*]}----"

cnt=0
while [ $cnt -lt ${#VAR[*]} ]
do
echo "$cnt--${VAR[$cnt]}"
      cnt=$(( $cnt + 1 ))
done

Code:
Output
0--5|EOF 89|840 45|454 45|454

# 10  
Old 01-27-2014
Got the solution!!!

Hi All,
A simple for loop helped me. Please see below
Code:
VAL="567|32 3434|3223 4545|343"
for i in $VAL
do   
   STARTPT=`echo $i|cut -d"|" -f1`
   ENDPT=`echo $i|cut -d"|" -f2`
   if [ ${STARTPT} != "" ] && [ ${ENDPT} == "EOF" ]
   then
     echo "IN SUCCESS CONDITION--"$STARTPT
   else
     echo "IN FAILED CONDITION--"$STARTPT"|"$ENDPT
    fi
done

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