# Execution problem with ksh

**URL:** <https://community.unix.com/t/execution-problem-with-ksh/290809>\
**Category:** Shell Programming and Scripting\
**Created:** [July 1, 2011, 11:39am UTC](https://community.unix.com/t/execution-problem-with-ksh/290809 "2011-07-01T11:39:54Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![saps19](https://community.unix.com/user_avatar/community.unix.com/saps19/32/13993_2.png) [@saps19](https://community.unix.com/u/saps19)\
**Post date:** [July 1, 2011, 11:39am UTC](https://community.unix.com/t/execution-problem-with-ksh/290809/1 "2011-07-01T11:39:54Z")

</div>

Dear All,

I have a script as follows:

```nohighlight
     1 #! /bin/ksh
     2 #
    28 varDate=`date +%d%h%y`
    29 export spool_file=/app/my_user/work/TH_Status_${varDate}_Check.txt
    30
    31 #########################
    32 # Unix Code Starts here #
    33 #########################
    34
    35 echo 'Please Enter Database Password: '
    36 stty -echo
    37 read db_pass
    38 stty echo
    39
  40 #-------------- Define Function for reusing ---------------#
  41
  42 displayResult()
  43 {
    44 echo '\nPlease Enter the Hub name (EMEA/APAC): '
    45 read u_region_nm
    46 p_region_nm=`echo $u_region_nm|tr '[a-z]' '[A-Z]'`
    47 echo 'Extracting information, please wait...\n'
    48
    49 ###############################
    50 # Database connection started #
    51 ###############################
    52
    53 sqlplus -s user_nm/$db_pass@my_db <<ENDOFSQL
    54
    55 WHENEVER SQLERROR EXIT 1
    56
    57 set serveroutput on size 1000000
    58 set echo off
    59 set feedback off
    60 set heading off
    61 set pages 0
    62 set pagesize 1000
    63 set linesize 300
    64 spool $spool_file
    65
    66 /* PL/SQL block starts from here */
    67
    68 declare
------your pl/sql code here
   244 exception
------your pl/sql code here
   251 end ;
   252 /
   253 spool off
   254 exit;
   255 ENDOFSQL
   256
   278 # Print the end programe message
   279 echo '\n-= Data Extraction file created! =-'
 280 }
 281
 282 #---------- Calling the function displayResult ----------#
 283 displayResult
 284
 285 #---------- Code for Exit Confirmation ----------#
 286
 287 exitConf()
 288 {
 289 echo 'Do you want to continue with other Hubs[y/n]?'
 290 read varWish
 291 varWish=`echo $varWish|tr '[a-z]' '[A-Z]'`
 292 if ["$varWish" == "Y"]; then
 293 displayResult # Calling the function
 294 exitConf # Calling the function
 295 elif ["$varWish" == "N"]; then
 296 echo '\nExit confirmation received. Exiting...!'
 297 else
 298 echo '\nInvalid option!'
 299 exitConf # Calling the function
 300 fi
 301 }
 302 exitConf
   303
   304 ###########################
   305 # End of Script Programme #
   306 ###########################
   307

```

Later, I have added the bold section code. After that the code is throwing the following error:

```nohighlight
th_status_chk.ksh[42]: syntax error at line 53 : `<<' unmatched

```

Earlier It was working fine.

Please help.  
Sapy.

---

<div class="post-metadata">

**Author:** ![methyl](https://community.unix.com/letter_avatar/methyl/32/5_5575768a8748004e209b776fc1b2916d.png) [@methyl](https://community.unix.com/u/methyl)\
**Post date:** [July 1, 2011, 1:11pm UTC](https://community.unix.com/t/execution-problem-with-ksh/290809/2 "2011-07-01T13:11:50Z")

</div>

This line must start in column 1.

```nohighlight
ENDOFSQL

```

---

<div class="post-metadata">

**Author:** ![kshji](https://community.unix.com/user_avatar/community.unix.com/kshji/32/15661_2.png) [@kshji](https://community.unix.com/u/kshji)\
**Post date:** [July 1, 2011, 1:15pm UTC](https://community.unix.com/t/execution-problem-with-ksh/290809/3 "2011-07-01T13:15:13Z")

</div>

ENDOFSQL must be in the position 1 in the line. The most safety method to fix.

```nohighlight
exitConf()
{
while true
do
  echo
  printf "Do you want to continue with other Hubs[y/n]?"
  read varWish
  case "$varWish" in
         Y|y) displayResult ;;
         n|N) echo "Exit confirmation received. Exiting...!"
                return 0
                ;;
         *) echo "Invalid option!" ;;
  esac
done
}

```

---

<div class="post-metadata">

**Author:** ![saps19](https://community.unix.com/user_avatar/community.unix.com/saps19/32/13993_2.png) [@saps19](https://community.unix.com/u/saps19)\
**Post date:** [July 4, 2011, 7:50am UTC](https://community.unix.com/t/execution-problem-with-ksh/290809/4 "2011-07-04T07:50:54Z")

</div>

Thank you [methyl](http://www.unix.com/members/302038815.html), later I found out that the "ENDOFSQL" should be in column 1 Position.
