Visit Our UNIX and Linux User Community


Execution problem with ksh


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Execution problem with ksh
# 1  
Old 07-01-2011
Execution problem with ksh

Dear All,

I have a script as follows:
Code:
     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:
Code:
th_status_chk.ksh[42]: syntax error at line 53 : `<<' unmatched

Earlier It was working fine.

Please help.
Sapy.
# 2  
Old 07-01-2011
This line must start in column 1.
Code:
ENDOFSQL

This User Gave Thanks to methyl For This Post:
# 3  
Old 07-01-2011
ENDOFSQL must be in the position 1 in the line. The most safety method to fix.

Code:
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
}

This User Gave Thanks to kshji For This Post:
# 4  
Old 07-04-2011
Thank you methyl, later I found out that the "ENDOFSQL" should be in column 1 Position.

Previous Thread | Next Thread
Test Your Knowledge in Computers #349
Difficulty: Easy
AWK was originally written in 1977 and distributed with Version 7 Unix.
True or False?

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Sequential execution of commands in ksh

I need to run few commands in a ksh script sequentially. Some of the commands are jobs submitted to the server and the consecutive commands are dependent on the completion of the jobs submitted to the server. It works if i separate the commands into different files like this #!/bin/ksh... (1 Reply)
Discussion started by: prashob123
1 Replies

2. UNIX for Dummies Questions & Answers

Execution problem

How to search a pattern from multiple files... i used the command suppose the pattern name is xxx grep xxx (file1-o- file2-o- file3) Thanks in advance (4 Replies)
Discussion started by: ksakil
4 Replies

3. Shell Programming and Scripting

Execution of KSH after the Other ENDS

I have couple of scripts which I may have to execute one after the other. The Script1 creates trg files and second sciprt need to look for this trg file and proces further. I read in the forum that (./test1.sh && ./test2.sh) would work. Can you please let me know how do i use this where I need to... (3 Replies)
Discussion started by: Sukruth Kumar
3 Replies

4. Shell Programming and Scripting

Execution problem

Hi, I have been trying to run a simple script CONFIG_FILE="/jay/check" . . . for i in `cat $CONFIG_FILE` do loc=`echo $i | cut -d "|" -f2` var=$(find $loc -mtime -1|wc -l) if then echo $loc has files older than 1 day fi done . . . (2 Replies)
Discussion started by: jayii
2 Replies

5. Shell Programming and Scripting

Execution problem

hi all, when i tried executing the script by giving following command $ sh test.sh <parameter> it shows the following output: <none> status code=0 Previously it was working fine.But now its showing this output. (1 Reply)
Discussion started by: sanjay mn
1 Replies

6. UNIX for Dummies Questions & Answers

execution problem

HI I am trying to check the status of port using command /code: netstat -an | grep port /Output: *.2009 *.* 0 0 65535 0 LISTEN what i am trying to do is i want to grep only status Wether the port is established/listen if so show ok else... (1 Reply)
Discussion started by: esumiba
1 Replies

7. UNIX for Dummies Questions & Answers

execution problem

Hi i am using expect module and trying to login using following code. ssh 127.0.0.1 expect "word:" send "$password \n" kindly let me know the login script using expect module (1 Reply)
Discussion started by: esumiba
1 Replies

8. Shell Programming and Scripting

ksh file execution problem

Hi, There is a ksh file as below /scripts/dir> ls -ltr script.ksh -rwxrwxrwx 1 oprlxr lxr 4937 Aug 19 11:13 script.ksh i logged on to the server with my ID and able to see the above file. I tried executing it but it was shoing below error. (JSKOBS) /scripts/dir>... (2 Replies)
Discussion started by: JSKOBS
2 Replies

9. Shell Programming and Scripting

KSH - Execution Time

Hello, I am on solaris 9 (KSH). I need to get the execution time of my script. I can't use the time command as I have to send by mail the result in a human readable way. So I am looking for a code to add to my script. The output result would be : Execution time :... (1 Reply)
Discussion started by: Aswex
1 Replies

10. Shell Programming and Scripting

How to create file execution in KSH shell

Dear all, I'm new in Unix system, I need help about how to create execution file. for example in my system i have file fg* when i open fg file i get : cmd='basename$0' $cmd "$@" how to create file like that (execution file) in KSH shell thank you for your help heru (4 Replies)
Discussion started by: heru_90
4 Replies

Featured Tech Videos