I want to run a sqlplus command from shell script and check the status of sqlplus command from shell script (i.e. success or failure i.e. in bash it's $? ). Can you provide me hints on how to do that?
For example following script works, but I am interested in a shell script which will tell me whether the schema/account has "alter database link" privileges or not (i.e. how the shell script can interpret output of sqlplus and tell me whether it's success or failure) -
#!/bin/bash
schema=$1
password=$2
database=$3
echo "schema is $schema"
echo "password is $password"
echo "database is $database"
sqlplus -s "$schema/$password@$database" <<ENDOFSQL
SET SPACE 0
SET LINESIZE 80
SET PAGESIZE 0
SET ECHO OFF
SET FEEDBACK OFF
SET VERIFY OFF
SET HEADING OFF
SET MARKUP HTML OFF SPOOL OFF
select privilege from session_privs where PRIVILEGE = 'ALTER DATABASE LINK';
exit;
ENDOFSQL
##### END OF SCRIPT
Thanks in advance. -Shashi Divekar