Error in Shell Script - Can anyone help Pls


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Error in Shell Script - Can anyone help Pls
# 1  
Old 08-12-2011
Error in Shell Script - Can anyone help Pls

Please find my shell script below

-------------------------------------

Code:
#!/usr/bin/ksh
ORAUSER=$1
P_REQUEST_ID=$4
current_time=`date +%m%d%y.%H%M%S`
echo "Process started at `date +%m/%d/%y.%H:%M:%S`"

#Intialize Variables
export SHLIB_PATH=/usr/local/lib
ext=".pdf"
ps_ext=".ps"
P_PROJ_NO=$5
P_JOB_FROM=$6
P_JOB_TO=$7
PRINTER=$8
P_ORG_CODE=$9

USR=`echo $1|cut -f9 -d " "|cut -f2 -d '"'`
export USR
echo $USR

# Call the Procedure gb_xml_report_attachment.gb_insert_values to insert values

echo 'Before Calling SQLPLUS: gb_xml_report_attachment.gb_insert_values..'

echo 'Displaying all Parameters .....'

echo 'P_REQUEST_ID:-'
echo $P_REQUEST_ID

echo 'P_ORG_CODE :-'
echo $P_ORG_CODE

echo 'P_PROJ_NO :-'
echo $P_PROJ_NO

echo 'P_JOB_FROM :-'
echo $P_JOB_FROM

echo 'P_JOB_TO :-'
echo $P_JOB_TO

sqlplus -s $USR <<EOF
execute gb_xml_report_attachment.gb_insert_values ($P_REQUEST_ID,'$P_ORG_CODE','$P_PROJ_NO','$P_JOB_FROM','$P_JOB_TO');
EXIT;
EOF

NO_OF_COUNT=`sqlplus -s $USR<<EOF
set heading off
set feedback off
select COUNT (1) from gb_job_report_tbl;
EOF`

echo 'NO_OF_COUNT'
echo $NO_OF_COUNT

integer i=0
while ((i < $NO_OF_COUNT));
do
  (( i = i + 1));
  echo 'Entering into Loop..'
  
  echo 'Before Calling SQLPLUS: Fetching File ID..'
    
  FILE_ID=`sqlplus -s $USR<<EOF
  set heading off
  set feedback off
  select file_id from gb_job_report_tbl where record_id =$i AND conc_request_id=$P_REQUEST_ID;
  EXIT;
  EOF`
  
  echo 'File ID :-'
  echo $FILE_ID
  
  JOB_NO=`sqlplus -s $USR<<EOF
  set heading off
  set feedback off
  select job_no from gb_job_report_tbl where record_id =$i AND conc_request_id=$P_REQUEST_ID;
  EXIT;
  EOF`
  
  echo 'JOB No :-'
  echo $JOB_NO
  
  echo 'Before Calling SQLPLUS: gb_xml_report_attachment.gb_run_report..'
  
  #Run the Job Report Using the JOB_NO
  sqlplus -s $USR<<EOF
  set heading off
  set feedback off
  execute gb_xml_report_attachment.gb_run_report('$P_ORG_CODE','$P_PROJ_NO','$JOB_NO','$JOB_NO','$PRINTER');
  EXIT;
  EOF
   
  PS_FILE=$FILE_ID$ps_ext
  
  FNDGFU $USR 0 Y DOWNLOAD=`echo $FILE_ID` $FILENAME
  pdf2ps $FILENAME $PS_FILE
  lp -d $PRINTER $FILE_ID$ps_ext
  rm $FILENAME
  rm $PS_FILE
  rm *.log
  rm *.out
done

# Call the Procedure gb_xml_report_attachment.gb_delete_values to delete values
sqlplus -s $USR<<EOF
set heading off
set feedback off
execute gb_xml_report_attachment.gb_delete_values ($P_REQUEST_ID);
EXIT;
EOF






I am getting the following error

-------------------------------------

Code:
Before Calling SQLPLUS: gb_xml_report_attachment.gb_insert_values..
Displaying all Parameters .....
P_REQUEST_ID:-
37950775
P_ORG_CODE :-
BAR
P_PROJ_NO :-

P_JOB_FROM :-
1546148
P_JOB_TO :-
1546148

PL/SQL procedure successfully completed.

NO_OF_COUNT
6
/dv01/appdev/devappl/wgt/11.5.0/bin/gb_invoke_xml_attachments.prog[77]: syntax error at line 80 : `do' unmatched
/dv01/appdev/devappl/wgt/11.5.0/bin/gb_invoke_xml_attachments
Program exited with status 2


Can anyone help me !!!!!!!

Last edited by pludi; 08-12-2011 at 02:38 PM..
# 2  
Old 08-12-2011
In ksh(88), you can not use less than as '<'.
Code:
integer i=0
while ((i < $NO_OF_COUNT));
do
  (( i = i + 1));
  echo 'Entering into Loop..'

Try
Code:
-lt

.

You appear to be mixing ksh88 and ksh93 syntax a lot.
# 3  
Old 08-12-2011
If you had used [CODE] tags, the first reply probably would have been that the token ending a here-doc (in your case it's always EOF) has to start on the very first character of the line, even when enclosed in backticks.
This User Gave Thanks to pludi For This Post:
# 4  
Old 08-12-2011
Exactly.. I saw there were extra spaces before the command started. When i removed the spaces the commands worked !!!
# 5  
Old 08-12-2011
Quote:
Originally Posted by pludi
the token ending a here-doc (in your case it's always EOF) has to start on the very first character of the line, even when enclosed in backticks.
While you are right on the mark in this case and with regard to this code's usage, I would just like to add, for the benefit of any sh novices, that there is a different here-doc operator, <<-, which strips leading tab characters, allowing indented code (including the here-doc delimiter).

Regards,
Alister
Login or Register to Ask a Question

Previous Thread | Next Thread

8 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Shell Script with following awk command pls help

Hi I want to create a shell script with the following awk command & also get the filenames in output. awk '/<catetcsecuretty0>/ {p=1} /<catvarlogmessages0>/ {p=0} p' *.xml As there will be multiple outputs related to many xml files I cannot identify which output belongs to which file ... (5 Replies)
Discussion started by: sharp488
5 Replies

2. Shell Programming and Scripting

Need help with first shell script pls.

Hi, I'm trying to extract information from one file to update another one and am a bit stuck. the first file is made up of tags e.g. <item>a@b.com</item> jksdhfjkdsh sldkjfds l klsjdf <item> c@d.com </item> what i'd like to do is extract the email addresses between these tags,... (6 Replies)
Discussion started by: newb1000
6 Replies

3. Shell Programming and Scripting

shell script, pls help

# for i in `cat oo`;do ls -ld $i;done ls: /var/tmp/i: No such file or directory ls: i: No such file or directory ls: /var/tmp/ii: No such file or directory ls: i: No such file or directory ls: /var/tmp/iii: No such file or directory ls: i: No such file or directory ls: /var/tmp/iiii: No such... (2 Replies)
Discussion started by: cpttak
2 Replies

4. Shell Programming and Scripting

Shell Script Required? Pls. help me

Hi All, I have Information in the file like, ============ Interface Information ==================== +++++++++++++++++ NMInterface ++++++++++++++ ObjID:251c55a2-2257-71dd-0f68-9887a1f10000 NNMObjID:82857 EntityName:aust00m1.mis.amat.com ] Description:ATM9/0/0-atm layer Discovered in... (22 Replies)
Discussion started by: ntgobinath
22 Replies

5. UNIX for Advanced & Expert Users

cp script error, pls help in debugging!!!!

Hi all, I searched to find out a few cp scripts that had progress bar, but did not compromise on performance, when my efforts were in vain i went ahead and wrote one of my own ,taking i/p frm other scripts... But this is causing some errors and am unable to debug it.....pls help Here is the... (1 Reply)
Discussion started by: wrapster
1 Replies

6. Shell Programming and Scripting

Shell Script Requirements pls

Moderators note: This user has been banned for persistent rule breaking despite being warned that this would be the result. (0 Replies)
Discussion started by: tt1ect
0 Replies

7. Shell Programming and Scripting

Unix shell script couldn't be executed. Pls help!

I have wrriten a script to call sql script to do some work in database. However, the script couldn't be executed. The only information was: ksh: ./updt_attrib.ksh cannot execute. Please help me to identify where the problem is. I post script here for your reference. Thanks a lot. #!/bin/ksh ... (8 Replies)
Discussion started by: duke0001
8 Replies

8. Shell Programming and Scripting

Passing value from shell script to .pls file

I have a shell script which takes at the command prompt options like ss1.sh -F SCOTT -T JOHN F- From User T- To User I want to pass the From User(SCOTT) Value to another script ss2.pls (This script runs a PL/SQL Program). Depending on the FromUser value in the ss1.sh script i have to... (4 Replies)
Discussion started by: dreams5617
4 Replies
Login or Register to Ask a Question