getting the error 'not found' while executing the script

Hi,

I am not able to figure out what the problem is:

getting the following error

sqltst.sh[19]: 1:  not found

here is the script

#!/bin/sh

. /home/dev1/.profile
. /home/dev1/.infenv

`sqlplus -s $REPDB_LOGON << EOF
SET SERVEROUT ON
SET FEEDBACK OFF
SET HEADING OFF
SET TRIMSPOOL ON
SET TIMING OFF
SET TERMOUT OFF
SET LINES 160
SPOOL $scripts_path/test.temp
select 1 from dual;
SPOOL OFF
SET SERVEROUT OFF
exit
EOF`

Please let me know where it went wrong.

-Sam

The behavior you observe is correct, the command substitution returns 1 and your shell tries to execute it as a command. Since there is no such command (1),
you're getting an error.

What exactly are you trying to achieve?

radoulov,

Thanks for the reply. I want to query a relation table and spool the output into a file.

I will use this spool file in later part of the script which i have not given in this post.

-Sam

OK,
just remove the back quotes from the here-document.

Change this:

`sqlplus -s $REPDB_LOGON << EOF
SET SERVEROUT ON
SET FEEDBACK OFF
SET HEADING OFF
SET TRIMSPOOL ON
SET TIMING OFF
SET TERMOUT OFF
SET LINES 160
SPOOL $scripts_path/test.temp
select 1 from dual;
SPOOL OFF
SET SERVEROUT OFF
exit
EOF`

to

sqlplus -s $REPDB_LOGON << EOF
SET SERVEROUT ON
SET FEEDBACK OFF
SET HEADING OFF
SET TRIMSPOOL ON
SET TIMING OFF
SET TERMOUT OFF
SET LINES 160
SPOOL $scripts_path/test.temp
select 1 from dual;
SPOOL OFF
SET SERVEROUT OFF
exit
EOF
1 Like

Thanks for your input. It's working now.

-Sam