Sponsored Content
Top Forums Shell Programming and Scripting Error while executing the shell script Post 302950772 by svajhala on Tuesday 28th of July 2015 02:32:26 PM
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

 

10 More Discussions You Might Find Interesting

1. 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

2. 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

3. 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

4. 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

5. 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

6. 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

7. 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

8. 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

9. 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

10. 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
exit(1) 							   User Commands							   exit(1)

NAME
exit, return, goto - shell built-in functions to enable the execution of the shell to advance beyond its sequence of steps SYNOPSIS
sh exit [n] return [n] csh exit [ ( expr )] goto label ksh *exit [n] *return [n] DESCRIPTION
sh exit will cause the calling shell or shell script to exit with the exit status specified by n. If n is omitted the exit status is that of the last command executed (an EOF will also cause the shell to exit.) return causes a function to exit with the return value specified by n. If n is omitted, the return status is that of the last command exe- cuted. csh exit will cause the calling shell or shell script to exit, either with the value of the status variable or with the value specified by the expression expr. The goto built-in uses a specified label as a search string amongst commands. The shell rewinds its input as much as possible and searches for a line of the form label: possibly preceded by space or tab characters. Execution continues after the indicated line. It is an error to jump to a label that occurs between a while or for built-in command and its corresponding end. ksh exit will cause the calling shell or shell script to exit with the exit status specified by n. The value will be the least significant 8 bits of the specified status. If n is omitted then the exit status is that of the last command executed. When exit occurs when executing a trap, the last command refers to the command that executed before the trap was invoked. An end-of-file will also cause the shell to exit except for a shell which has the ignoreeof option (See set below) turned on. return causes a shell function or '.' script to return to the invoking script with the return status specified by n. The value will be the least significant 8 bits of the specified status. If n is omitted then the return status is that of the last command executed. If return is invoked while not in a function or a '.' script, then it is the same as an exit. On this man page, ksh(1) commands that are preceded by one or two * (asterisks) are treated specially in the following ways: 1. Variable assignment lists preceding the command remain in effect when the command completes. 2. I/O redirections are processed after variable assignments. 3. Errors cause a script that contains them to abort. 4. Words, following a command preceded by ** that are in the format of a variable assignment, are expanded with the same rules as a vari- able assignment. This means that tilde substitution is performed after the = sign and word splitting and file name generation are not performed. ATTRIBUTES
See attributes(5) for descriptions of the following attributes: +-----------------------------+-----------------------------+ | ATTRIBUTE TYPE | ATTRIBUTE VALUE | |Availability |SUNWcsu | +-----------------------------+-----------------------------+ SEE ALSO
break(1), csh(1), ksh(1), sh(1), attributes(5) SunOS 5.10 15 Apr 1994 exit(1)
All times are GMT -4. The time now is 02:52 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy