Visit Our UNIX and Linux User Community


Error while executing the shell script


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Error while executing the shell script
# 1  
Old 07-28-2015
Error while executing the shell script

Hi Gurus,

The following script fails with the error 'command not found' while trying to execute. As the error indicates, the script fails at ROW#30 where the EOF is defined for SQL statement.

It appears that the script is trying execute the lines in the SQL output written to ta spool file. However in the end, script performs the tasks as specified. But i need to have a clean exit after the execution so that I can promote it to production environment.

Code:
#!/bin/sh
. ${HOME}/.bash_profile
. ${scripts}/.dr_env.cfg
logfile=${logs}/update_ldr_conn.log
export TmpFile=$scripts/ctrl/temp.$$
printf "\n==========================================================================" >> $logfile
printf "           `date` : Loader Connection update script \n" >> $logfile
printf "\n==========================================================================" >> $logfile
`sqlplus -s $SQL_LOGON << EOF
SET SERVEROUT ON
SET FEEDBACK OFF
SET HEADING OFF
SET TRIMSPOOL ON
SET TIMING OFF
SET TERMOUT OFF
SET LINES 160
SPOOL ${TmpFile}
SELECT CN.OBJECT_NAME,AT.ATTR_VALUE FROM OPB_CNX CN, OPB_CNX_ATTR AT WHERE CN.OBJECT_ID=AT.OBJECT_ID AND AT.ATTR_VALUE = '${TD_PRD_DB}';
SPOOL OFF
SET SERVEROUT OFF
exit
EOF`
echo $RC
RC=$?
if [ $RC -eq 0 ] ; then
        printf "\nSuccessfully selected the rows." >> $logfile
  else
        printf "\nError! while trying to run the select query." >> $logfile
        exit 1
 fi
if [[ -s ${TmpFile} ]] ; then

printf "\nThe following TD Loader connections will be updated with DR Server information." >> $logfile
cat ${TmpFile} >> $logfile

`sqlplus -s $SQL_LOGON << EOF
SET SERVEROUT ON
SET FEEDBACK OFF
SET HEADING OFF
SET TIMING OFF
SET TERMOUT OFF
SET LINES 160
UPDATE OPB_CNX_ATTR SET ATTR_VALUE='${TD_DR_DB}' WHERE ATTR_VALUE='${TD_PRD_DB}';
COMMIT;
SET SERVEROUT OFF
exit
EOF`
echo $RC
RC=$?
if [ $RC -eq 0 ]
then
        printf "\nSuccessfully updated the TD DR Database name in the Loader connections." >> $logfile
        exit 0

ERROR
Code:
./ldr_conn_update.sh: line 30: TD_Tpump_Insert: command not found

0

# 2  
Old 07-28-2015
Are you sure you posted the right script? Line 30 is NOT the EOF, and the command TD_Tpump_Insert causing the err msg is not found anywhere in the script.
And, remove the space before the EOF!
# 3  
Old 07-28-2015
also you may want to swap these 2 lines:
Code:
echo $RC
RC=$?

# 4  
Old 07-28-2015
Hi RudiC,

As mentioned earlier, script is throwing an error from the first line of output from the SQL spool file, which is
TD_Tpump_InsertAs you suggested, I have removed the space before EOF and tried it, but still it fails with the same error.
# 5  
Old 07-28-2015
you don't need 'active function' for sqlplus - remove the` from `sqlplus -s $SQL_LOGON and from EOF`
This User Gave Thanks to vgersh99 For This Post:
# 6  
Old 07-28-2015
Just for clarity, here I am pasting the output of the spoolfile created by the SQL statement.

Code:
inform@pocinf09:/app/prod/informat/Scripts/ctrl:#cat temp.21791

TD_Tpump_Insert
TDEDW

TD_TRUNCATE_FASTLOAD
TDEDW

TD_Tpump_Upsert
TDEDW

TD_Tpump_Update
TDEDW

TD_Tpump_Delete

TDEDW

TD_Mload_Upsert
TDEDW

TD_Mload_Update
TDEDW

TD_MLOAD_UPSERT_DYNAMIC
TDEDW

TD_MLOAD_INSERT_DYNAMIC
TDEDW


SIEBEL_TD_OLAP_TPUMP_INSERT_DYNAMIC
TDEDW

SIEBEL_TERADATA_MLOAD_INSERT_DYNAMIC
TDEDW

# 7  
Old 07-28-2015
see suggestions above

Previous Thread | Next Thread
Test Your Knowledge in Computers #12
Difficulty: Easy
CPU stands for 'Computer Processing Unit' and controls all of a computer's functions, acting as the brain(s) of computers.
True or False?

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Why we use -f while executing any shell script?

Hi All, I wanted to know why we use the '-f' option while executing script. in my case... abcd.sh -f any_evts 02 2014 abcd = Scriptname -f = dont know any_evts = Some file or string 02= month 2014 = year So in above pleas ehelp to understand here -f and other arguement like... (1 Reply)
Discussion started by: ajju
1 Replies

2. Shell Programming and Scripting

SP2-0642 error while executing procedure from shell script

hi all, i have a unix script where i am calling a database procedure from it. while executing the procedure i am getting an error: but when i tried to call the same procedure manually then it ran successfully, i goggled this issue and found timezone.dat file missing at... (0 Replies)
Discussion started by: lovelysethii
0 Replies

3. Shell Programming and Scripting

Executing a shell script using sh

Platform : Solaris 10, RHEL 5.4, OEL 6 I've noticed that some of my colleagues execute scripts by typing sh before the script name sh myscript.shI always execute a script by typing the script name and typing enter provided PATH variable has . (current directory) in it myscript.sh (and... (1 Reply)
Discussion started by: John K
1 Replies

4. Shell Programming and Scripting

error when executing shell scrpit

Guys, when i am executing the following script I am getting following error. -bash: test.sh: command not found $ test.sh -- script name #! /bin/bash echo " Job started........" CURRENTDIR=`pwd` exit 0 thanks Please view this link: How to use ... tags (2 Replies)
Discussion started by: skatpally
2 Replies

5. Shell Programming and Scripting

SFTP-how to log individual sftp command error while executing shell script

Hi, I have situation where i need to automate transferring 10000+ files using sftp. while read line do if ; then echo "-mput /home/student/Desktop/folder/$line/* /cygdrive/e/folder/$line/">>sftpCommand.txt fi done< files.txt sftp -b sftpCommand.txt stu@192.168.2.1 The above... (1 Reply)
Discussion started by: noobrobot
1 Replies

6. Linux

Error executing shell script in Linux

Hi, I have following shell script code : ------------------------------------------------------------------ #!/bin/bash SCRIPTS_DIR="/scriptsDir1" # tables login/password APIL_USER="uname/pswd" I2_USER="uname/pswd" # Database DB="db1" cd "$SCRIPTS_DIR/scriptsDir2" sqlplus... (1 Reply)
Discussion started by: Chaitrali
1 Replies

7. Shell Programming and Scripting

Error executing shell script in Linux

Hi, I have following shell script code : ------------------------------------------------------------------ #!/bin/bash SCRIPTS_DIR="/scriptsDir1" # tables login/password APIL_USER="uname/pswd" I2_USER="uname/pswd" # Database DB="db1" cd "$SCRIPTS_DIR/scriptsDir2" sqlplus... (2 Replies)
Discussion started by: Chaitrali
2 Replies

8. Shell Programming and Scripting

Error executing shell command from a perl script

Hi Gurus, I've a find command that gets the list of files from a source directory where the extension is not html, xml, jsp, shtml or htaccess. The below find command runs fine from the command prompt or in a shell script. I need to eventually run it in a PERL script and am getting the... (5 Replies)
Discussion started by: voorkey
5 Replies

9. Shell Programming and Scripting

Error message while executing the shell script

Hi All, When I am trying to execute the below shell script I got this error message. script ========== #!/bin/bash /usr/java/jdk1.5.0_10/bin/java - classpath /var/lib/asterisk/agi-bin/mysql-connector-java-3.0.15-ga-bin.jar/: /var/lib/asterisk/agi-bin/jarfiles:... (4 Replies)
Discussion started by: ajayyaduwanshi
4 Replies

10. UNIX for Dummies Questions & Answers

Executing a Shell Script

I am trying to run a shell script using the ./<ScriptName> command, but the server returns an error bash: ./Script1.sh: Permission denied What variable do I need to set to avoid this? (4 Replies)
Discussion started by: igandu
4 Replies

Featured Tech Videos