Home » Infrastructure » Unix » Accessing SQL session from UNIX shell script
Accessing SQL session from UNIX shell script [message #127816] Wed, 13 July 2005 09:08 Go to next message
pravisri
Messages: 10
Registered: March 2005
Location: Manchester
Junior Member
I am writing a UNIX script to execute some SQL and PL/SQL blocks sequentially by passing parameters into the UNIX script. One of my parameters is Oracle database userid/password and the database schema name. The passed parameter will be somewhat like this cnc/cnc@nexp; How can I check from the UNIX script whether the passed parameters are correct ?

Many Thanks & Kind Regards
Srinivas
Re: Accessing SQL session from UNIX shell script [message #127985 is a reply to message #127816] Thu, 14 July 2005 08:28 Go to previous messageGo to next message
oralew
Messages: 4
Registered: July 2005
Junior Member
Are you just checking the format of the parameters ie. user/password@xxxx ?
Re: Accessing SQL session from UNIX shell script [message #128000 is a reply to message #127816] Thu, 14 July 2005 09:31 Go to previous messageGo to next message
pravisri
Messages: 10
Registered: March 2005
Location: Manchester
Junior Member
No; I want to check using that parameter can I Login to a SQL sessions or not

Thanks
Re: Accessing SQL session from UNIX shell script [message #128018 is a reply to message #128000] Thu, 14 July 2005 11:02 Go to previous messageGo to next message
oralew
Messages: 4
Registered: July 2005
Junior Member
I do it by checking the posix return from the sqlplus connection command in the script e.g.

#!/bin/ksh

sqlplus -s user/password@schema << EOF > /dev/null

select count (*) from table
/
exit
EOF

echo "SQL status was $?\n"

###########################################

When testing if I enter an incorrect user or password the exit status is 1 as opposed to exit status of 0 if correct user and password are used. A simple test in the script can then tell you if the params were correct. Any help?
icon14.gif  Re: Accessing SQL session from UNIX shell script [message #128185 is a reply to message #127816] Fri, 15 July 2005 10:41 Go to previous messageGo to next message
oralew
Messages: 4
Registered: July 2005
Junior Member
In case anyone is interested the pw-syscall has been identified as a 32/64 bit kernel problem which should be solved by ora patch 2896876. Info provided by a friendly forum user.
Re: Accessing SQL session from UNIX shell script [message #128216 is a reply to message #128185] Fri, 15 July 2005 14:21 Go to previous message
andrew again
Messages: 2577
Registered: March 2000
Senior Member
Using sqlplus, it always prompts for a second and third try if the first fails (as far as I can remember). If this happens, your script will hang until it gets some "enters". I guess you could do that with "here documents" in a shell.

YSee if this helps...
http://www.orafaq.com/forum/t/48574/45693/
Previous Topic: Shell script to get rid the " - " on a string! how?
Next Topic: environment variables in export parameter files
Goto Forum:
  


Current Time: Tue Apr 23 19:50:04 CDT 2024