I have my script working almost. The purpose of this is to take certain values from the file, and then populate these valeus in the shell script at runtime.
Please see what I have here ...
First file: ab.sh
#!/bin/bash
USER_TYPE=$1
USERNAME=$2
PERMISSION_TYPE=$3
TARGET_USER=$4
TARGET_TABLE=$5
if [ $USER_TYPE == 'TYPE1' ]
then
cat Parameters.conf |while read USERNAME
do
sqlplus / as sysdba << E00
CREATE USER ${USERNAME}
DEFAULT TABLESPACE USERS
TEMPORARY TABLESPACE TEMP
ACCOUNT UNLOCK;
ALTER USER ${USERNAME} DEFAULT ROLE ALL;
GRANT CREATE SESSION TO ${USERNAME};
GRANT CONNECT TO ${USERNAME};
exit
E00
done
cat p.conf |while read PERMISSION_TYPE TARGET_SCHEMA TARGET_TABLE USERNAME
do
sqlplus / as sysdba > /home/o/output/output.log << E01
GRANT ${PERMISSION_TYPE} ON ${TARGET_USER}.${TARGET_TABLE} TO ${USERNAME};
E01
done
fi
This is the Parameters.conf file where the values are defined and should appear ...
Parameters.conf
USER_TYPE TYPE1
USERNAME NEWUSER
PERMISSION_TYPE SELECT,UPDATE
TARGET_USER TESTUSER
TARGET_TABLE ABC
source
share