Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9271077
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T15:31:44+00:00 2026-06-18T15:31:44+00:00

#!/bin/sh echo Please enter evaluate database username read eval_user echo Please enter evaluate database

  • 0
#!/bin/sh

echo "Please enter evaluate database username"
read eval_user
echo "Please enter evaluate database password"
read eval_pass
echo "Please enter the database name"
read db_name

LOGFILE=shell_log.txt

$ORACLE_HOME/bin/sqlplus -s /nolog <<-EOF>> ${LOGFILE}
connect $eval_user/$eval_pass@$db_name
WHENEVER OSERROR EXIT 9;
WHENEVER SQLERROR EXIT SQL.SQLCODE;
DBMS_OUTPUT.put_line('Connected to db');
EOF

if [ $? != 0 ]
then 
echo "The upgrade script failed. Please refer to the log results.txt for more information"
echo "Error code $?"
exit 0;
fi

I am entering garbage values trying to force this script to fail. But, annoyingly, it keeps moving ahead without any mention of any error code. What else needs to be done here?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T15:31:45+00:00Added an answer on June 18, 2026 at 3:31 pm

    What Max says is correct. Try this modified script

    #!/bin/sh
    
    echo "Please enter evaluate database username"
    read eval_user
    echo "Please enter evaluate database password"
    read eval_pass
    echo "Please enter the database name"
    read db_name
    
    LOGFILE=shell_log.txt
    
    sqlplus -s /nolog <<-EOF>> ${LOGFILE}
    WHENEVER OSERROR EXIT 9;
    WHENEVER SQLERROR EXIT SQL.SQLCODE;
    connect $eval_user/$eval_pass@$db_name
    DBMS_OUTPUT.put_line('Connected to db');
    EOF
    
    sql_return_code=$?
    
    if [ $sql_return_code != 0 ]
    then
    echo "The upgrade script failed. Please refer to the log results.txt for more information"
    echo "Error code $sql_return_code"
    exit 0;
    fi
    

    Please note the use of sql_return_code to capture the SQLPLUS return code.

    The DBMS_OUTPUT statement should fail with error – “SP2-0734: unknown command beginning…”. You can find the error message in log file.

    It is possible to trap the sp2 errors in SQLPLUS 11g using the error logging facility. Please have a look at http://tkyte.blogspot.co.uk/2010/04/new-thing-about-sqlplus.html for more information.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

#!/bin/bash echo Please enter your Host Name read hname echo You have entered $hname,
#!/bin/bash echo SCRIPT: $0 echo Enter Customer Order Ref (e.g. 100018) read P_CUST_ORDER_REF echo
#! /bin/bash echo Please input 2 nums: read a b if [ -z $b
#!/bin/bash array=($1 $2 $3 $4) if [ $# -ne 4 ]; then echo Please
What's wrong I get an error : ./greater[4]: [: argument expected #!/bin/ksh echo please
i have the following shell script- #!/bin/bash echo enter the full path of script;
I have a simple script named example : #!/bin/sh echo $'${1}' Please note that
Can anyone please explain this shell script? #!/bin/bash read a STR= $a ARR=($STR) LEN=${#ARR[*]}
Shell Script #! /bin/bash sqlplus -s <username>/<passwd>@dbname << EOF set echo on set pagesize
#!/bin/bash echo 'first line' >foo.xml echo 'second line' >>foo.xml I am a total newbie

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.