1

I am trying to understand a simple script that connects to Oracle database using sqlplus command in unix:

1 sqlplus -s /nolog > /dev/null 2>&1 <<EOF
2 whenever sqlerror exit failure
3 connect $user_pwd
4 exit success
5 EOF

If I am using unix then I use commands as sqlplus $user_pwd for connecting to oracle database and to come out of sqlplus command I use exit. Please help me in understanding the lines 1,2,4,5. It may be a simple question for experts but I am not able to understand when to use these.

1
  • Try searching for heredoc. Commented Feb 26, 2014 at 11:20

1 Answer 1

5
  • -s is for silent mode (not output anything)
  • > /dev/null 2>&1 things are for force to not display anything. (redirect standard output and standard error to /dev/null)
  • /nolog is for not trying to login with the command line arguments. (the login credentials aren't provided here.)
  • <<EOF is a heredoc input redirect. The lines until EOF will be passed to sqlplus as standard input. (So this is why the last line is EOF)
  • About the whenever line: http://docs.oracle.com/cd/B19306_01/server.102/b14357/ch12052.htm So the command's return value will be failure if something wrong happens.
  • connect $user_pwd connects the sqlplus to the server
  • The exit success makes sqlplus returning will success. http://docs.oracle.com/cd/B19306_01/server.102/b14357/ch12023.htm#i2697968
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.