2016-03-29 17 views
1

Tüm oluştur ve değiştir tablo komut dosyalarına sahip Alter_t_new.sql dosyasını çalıştırdığım bir kabuk komut dosyası oluşturdum. Şimdi ne olursa olsun hatalar olsun veya oluşturulsun shoul günlük dosyasına biriktirilmelidir. Ben SPOOL $ LOGFILE çalıştı ama bu bir hatayıNesne oluşturmayı günlük dosyası içine biriktirme

SPOOL: command not found 

shell script atıyor:

echo "Starting installation of XXHCM_OBJECTS - XXHCM_OBJECTS ..." 
echo "Starting installation of XXHCM_OBJECTS - XXHCM_OBJECTS ..." "">>$LOGFILE 
echo "">>$LOGFILE 

echo "">>$LOGFILE 
echo "Copying Files To Appropriate Directories ..." 
echo "Copying Files To Appropriate Directories ..." "">>$LOGFILE 


echo "">>$LOGFILE 


echo "">>$LOGFILE 
echo "Files copied successfully !!! " 
echo "Files copied successfully !!! " "">>$LOGFILE 
echo "">>$LOGFILE 

echo "Changing permissions ... "  "">>$LOGFILE 
chmod 777 *.* 
echo "Changed permissions ... "  "">>$LOGFILE 

echo "">>$LOGFILE 
echo "Creating Custom Package, Synonyms and Grants..." "">>$LOGFILE 
echo "Creating Custom Package, Synonyms and Grants..." 
echo "">>$LOGFILE 

if sqlplus $APPS_USER @Alter_t_new.sql 
then 
SPOOL $LOGFILE 
    echo "Custom itables created successfully in APPS schema"  "">>$LOGFILE 
    echo "Custom itables created successfully in APPS schema" 
    SPOOL OFF 
else 
    echo "Error in creating custom itables in APPS schema"  "">>$LOGFILE 
    echo "Error in creating Custom itables in APPS schema" 
fi 

echo "">>$LOGFILE 
echo "Package, Synonyms,grants and Tables created successfully" "">>$LOGFILE 
echo "Package, Synonyms,grants and Tables created successfully" 
echo "">>$LOGFILE 


echo "Installation completed for XXHCM_OBJECTS - XXHCM_OBJECTS" 
echo "Installation completed for XXHCM_OBJECTS - XXHCM_OBJECTS"  "">>$LOGFILE 
# ***************************************************************************** 
# End of Script 
# ***************************************************************************** 

cevap

0

Sen komut dosyası içinde SPOOL komutu kullanmalısınız, bu SQLPlus komut var. Örneğin dosya içeriği: Ayrıca çıkış bastırmak için SET TERMOUT OFF komutunu kullanabilirsiniz

SPOOL my_log.log 
CREATE TABLE t1 
    (col1 NUMBER); 
SPOOL OFF 

.

The TERMOUT setting controls whether SQLPlus displays output generated by SQL statements, PL/SQL blocks, and SQLPlus commands. This setting applies only when SQLPlus is executing a script file. SQLPlus displays output from commands entered interactively.

+0

@ hinotf- sunucuda my_log oluşturmam gerekecek mi? –

+0

@sreekembose günlük dosyası nerede oluşturuldu SQLPlus – hinotf

+0

çalıştı Bu teşekkürler! –

1

Bu SPOOL'un Alter_t_new.sql dosyasında bulunması gerekeceğine inanıyorum.

(from .sh script) 
    if sqlplus $APPS_USER @Alter_t_new.sql $LOGFILE 
    then 
     echo "Custom itables created successfully in APPS schema"  "">>$LOGFILE 
     echo "Custom itables created successfully in APPS schema" 
     SPOOL OFF 
    else 
     echo "Error in creating custom itables in APPS schema"  "">>$LOGFILE 
     echo "Error in creating Custom itables in APPS schema" 
    fi 


    (from Alter_t_new.sql) 
    WHENEVER SQLERROR EXIT SQL.SQLCODE 

    spool &1 APPEND 

SQLplus komutu

sqlplus $APPS_USER @Alter_t_new.sql $LOGFILE 

bir argüman olarak $ LOGFILE Geçme ve

eklemeler yapıyoruz günlük dosyasına eklemek için bu argümanı kullanarak: Böyle bir şey yapacağını
spool &1 APPEND 

Ayrıca, WHENEVER SQLERROR EXIT SQL.SQLCODE biti, hatayı bulamayan .sh dosyasına döndürmelidir. Aşağıda, WHENEVER SQLERROR: https://docs.oracle.com/cd/B19306_01/server.102/b14357/ch12052.htm

hakkında bazı bilgiler bulabilirsiniz.

İlgili konular