Here is my script

#!/bin/bash
stty intr ^C erase ^H kill ^U
p_id=`ps -ef|grep iucmh|grep iuc|grep MSC015|grep START|awk -F" " '{print $2}'`

vLogin=`echo "iucmh/iucmh123@4s_MH"`

if [ -z "$p_id" ]; then
     sqlplus -s ${vLogin} <<EOF
     set pagesize 0 
     feedback off 
     verify off 
     heading off 
     echo off;
     UPDATE  IUC_CON_PARAMETERS
     SET F_PARAM_VALUE=0
     WHERE F_PARAM_NAME LIKE 'MSC015_PROCESS_ID'
     EXIT;
EOF

    echo "Working"
#     fi
else
     echo "Process is already Running"
     fi

Running this script I get the following error:

Syntax error at line 18 : `<<' is not matched.
  • 3
    DOS newlines? There's no syntax error in the code. – Kusalananda Jun 22 '16 at 9:00
  • 1
    Why the convoluted vLogin=`echo "iucmh/iucmh123@4s_MH"` ? Just use vLogin="iucmh/iucmh123@4s_MH" – roaima Jun 22 '16 at 9:03
  • 1
    DOS newlines or other whitespace at the end of the 'EOF'? I get a different error message with bash 4.3.30, but a quick search on google hints at the whitespace. – ilkkachu Jun 22 '16 at 9:24

The code is OK and bash does not contain the error message you mention.

Try:

#!/bin/bash

if [ bla ]; then
     cat <<EOF
     set pagesize 0 
     feedback off 
     verify off 
     heading off 
     echo off;
     UPDATE  IUC_CON_PARAMETERS
     SET F_PARAM_VALUE=0
     WHERE F_PARAM_NAME LIKE 'MSC015_PROCESS_ID'
     EXIT;
EOF

    echo "Working"
#     fi
else
     echo "Process is already Running"
     fi

And verify. So I guess that your message is from the command sqlplus.

  • But sqlplus login is perfectly working fine ... – Deepak Jun 22 '16 at 9:05
  • did you verify where this error message is from? – schily Jun 22 '16 at 9:12
  • Guys this one more thing ..this script is running fine in sun .....but not working in hp ... – Deepak Jun 22 '16 at 10:24
  • No. sqlplus does not see the <<EOF, so it's the shell erroring out. Check the newlines for DOS line-endings instead. – Kusalananda Jun 22 '16 at 11:06
  • You missinterpret how such a script is working. The shell handles <<EOF and it does correctly, see my example. The only explanation is that sqlplus does not like the input it is given – schily Jun 22 '16 at 11:37

Your Answer

 

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.