2016-08-15 108 views
0

我在執行他的bash腳本時遇到問題。目前,接收到意外標記'fi'附近出現語法錯誤的錯誤。 「網絡連接」。shell腳本中意外標記'fi'附近的語法錯誤sqlplus

USER_TYPE=$1 #IDENTIFY USER TYPE TYPE1,TYPE2,TYPE3,TYPE4,TYPE5 
USER_NAME=$2 
TARGET_SCHEMA=$3 
TARGET_TABLE=$4 
PERMISSION_TYPE=$5 
if $USER_TYPE == 'TYPE1'; 
    then 
sqlplus/<< E00 
CREATE USER ${USER_NAME} 
IDENTIFIED BY "default" 
DEFAULT TABLESPACE USERS 
TEMPORARY TABLESPACE TEMP 
ACCOUNT UNLOCK; 
ALTER USER ${USER_NAME} DEFAULT ROLE ALL; 
GRANT CREATE SESSION TO ${USER_NAME}; 
GRANT CONNECT TO ${USER_NAME}; 
exit 
E00 
cat perm.txt |while read PERMISSION OWNER TABLE USER 
do 
sqlplus/as sysdba > /home/o/direct/Passa/output/output.log << E01 
GRANT $PERMISSION ON $OWNER.$TABLE TO $USER; 
E01 
fi 
+0

我將刪除sqlplus和Oracle標記,因爲這是一個shell腳本問題(「fi」與Oracle或sqlplus無關)。 – mathguy

+0

修復語法。請看看:http://www.shellcheck.net/ – Cyrus

回答

2

您缺少的while環路done關鍵字。

cat perm.txt |while read PERMISSION OWNER TABLE USER 
do 
sqlplus/as sysdba > /home/o/direct/Passa/output/output.log << E01 
GRANT $PERMISSION ON $OWNER.$TABLE TO $USER; 
E01 
done 
fi 

順便說一句,這是一個UUOC。您可以使用輸入重定向

while read PERMISSION OWNER TABLE USER 
do 
sqlplus/as sysdba > /home/o/direct/Passa/output/output.log << E01 
GRANT $PERMISSION ON $OWNER.$TABLE TO $USER; 
E01 
done < perm.txt 
while read PERMISSION OWNER TABLE USER 
do 
sqlplus/as sysdba > /home/o/direct/Passa/output/output.log << E01 
GRANT $PERMISSION ON $OWNER.$TABLE TO $USER; 
E01 
done < perm.txt 
+0

哈哈哇。非常感謝Barmar。當我回到我的辦公桌時,我會檢查它。 –

相關問題