The UNIX and Linux Forums  

Go Back   UNIX e Linux Forum > Inizio Forum > Shell scripting e di programmazione
.
google unix.com



Shell scripting e di programmazione Pubblica domande su KSH, CSH, SH, Bash, Perl, PHP, sed, awk e da altri script di shell e linguaggi di scripting shell qui.

Più di UNIX e Linux Forum Argomenti potreste trovare utili
Filo Thread Starter Forum Risposte Ultimo Post
Problema in script di shell arnie_nits Shell scripting e di programmazione 1 12-12-2007 10:13 AM
Problema script di shell shashi_kiran_v UNIX for Dummies Domande & Risposte 5 01-10-2007 11:49 AM
problema script di shell djt0506 UNIX for Dummies Domande & Risposte 2 12-07-2005 11:29 PM
Problema con script di shell zylwyz Shell scripting e di programmazione 2 06-29-2005 02:01 PM
Problema con script di shell nattynatty Shell scripting e di programmazione 4 04-09-2002 04:30 PM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Cerca in questo Thread Rate Thread Modalità di visualizzazione
  #1 (permalink)  
Old 11-18-2008
babu.knb babu.knb is offline
Utente Registrato
  
 

Iscriviti Data: Sep 2008
Località: India
Interventi: 7
Problema in script di shell


Codice:
 
HOSTNAME=`uname -n`
/usr/sbin/clinfo
CLUSTERACTIVE=$?
# First check whether the Cluster itself is active
if [ $CLUSTERACTIVE != "0" ]
  then
        echo Cluster is NOT ACTIVE - EXITING
          exit 1
  fi
# Now check whether we are on the active Cluster Node for this Resource Group
CLUSTERSTATE=`/usr/cluster/bin/scha_resource_get -R ora-db03-lh-rs -O RESOURCE_STATE_NODE $HOSTNAME`
if [ $CLUSTERSTATE != "ONLINE" ]
  then
        echo "Cluster is NOT ON ACTIVE CLUSTERNODE for this resource group - EXITING"
          exit 1
  fi
echo "Cluster status check OK"
### Cluster check done
# check whether correct User executes this Script
USERNAME=$LOGNAME
if [ ! $USERNAME = "root" ]
  then
        echo "WRONG USERNAME, must be User ROOT"
        exit 1
  fi
echo "User check OK"
### User check done
# Get command Line Parameters
INSTANCE=$1
USR=$2
# Now check whether required Parameter has been given on command Line
if [ ! $# = "2" ]
  then
        echo
        echo "Wrong number of Parameters or no Parameter have been given. USAGE: arc_aging.sh FIN/DIS ocafin1/oracle"
        echo
        exit 1
  else
        echo "Parameter count check OK"
  fi
# Now check whether valid Parameters have been given
if [ "$INSTANCE" = "FIN" -o "$INSTANCE" = "DIS" ]
  then
        echo "Parameter validation check OK"
  else
        echo "Parameter must be FIN or DIS !!"
        exit 1
  fi
if [ "$USR" = "ocafin1" -o "$USR" = "oracle" ]
  then
        echo "Parameter validation check OK"
  else
        echo "Parameter must be oracle or ocafin1 !!"
        exit 1
  fi
### Parameter check done
# Build local Environment Variables
INSTANCE_REDO=$1_REDO2
## Set the archive Directory
ARCH1="/global/$INSTANCE_REDO/archlogs"
ARCH2="/global/ORA_BACKUP/archlogs/$INSTANCE"
ARCH3="/global/ORA_BACKUP/archlogs/$INSTANCE/compressed"
ARCH4="/global/LOG_REPLICATION/$INSTANCE"
# Delete Archive logs on /global/LOG_REPLICATION/$INSTANCE volume when not accessed since 10 days
# These are the archive logs which where replicated to Euromoda/TIU via SNDR
echo "SNDR: Deleting Archive Logs on /global/LOG_REPLICATION/$INSTANCE older than 10 days ...."
date '+Start: %H:%M:%S'
echo "The following files are going to be deleted:"
su $USR -c "find $ARCH4 -type f -atime +10 -exec ls {} \;"
su $USR -c "find $ARCH4 -type f -atime +10 -exec rm {} \;"
echo Return code: $?
date '+End: %H:%M:%S'
# Delete Archive logs on /global/ORA_BACKUP volume when not accessed since 15 days
echo "Cleaning up Archive Logs on /global/ORA_BACKUP/archlogs/$INSTANCE/compressed older than 15 days ...."
date '+Start: %H:%M:%S'
echo "The following files are going to be deleted:"
su $USR -c "find $ARCH3 -type f -atime +10 -exec ls {} \;"
su $USR -c "find $ARCH3 -type f -atime +10 -exec rm {} \;"
echo Return code: $?
date '+End: %H:%M:%S'
 
# Compress Archive logs on /global/ORA_BACKUP volume when not accessed since 2 days
echo "Compressing Archive Logs on /global/ORA_BACKUP/archlogs/$INSTANCE older than 2 days ...."
date '+Start: %H:%M:%S'
su $USR -c "find $ARCH2 -name compressed -prune -o -type f -atime +2 -exec ls {} \;"
su $USR -c "find $ARCH2 -name compressed -prune -o -type f -atime +2 -exec compress {} \;"
echo Return code: $?
date '+End: %H:%M:%S'
# Move compressed files to subfolder
echo "Moving compressed files to subfolder ...."
date '+Start: %H:%M:%S'
su $USR -c "mv /global/ORA_BACKUP/archlogs/$INSTANCE/*.Z /global/ORA_BACKUP/archlogs/$INSTANCE/compressed"
su $USR -c "mv /global/ORA_BACKUP/archlogs/$INSTANCE/*.gz /global/ORA_BACKUP/archlogs/$INSTANCE/compressed"
echo Return code: $?
date '+End: %H:%M:%S'
# Move Archive logs from /global/(FIN/DIS)_REDO2/archlogs to the /global/ORA_BACKUP volume when not accessed since 1 day
echo "Moving Archive Logs to /global/ORA_BACKUP/archlogs/$INSTANCE older than 1 day ...."
date '+Start: %H:%M:%S'
su $USR -c "find $ARCH1 -name compressed -prune -o -type f -atime 1 -exec ls {} \;"
su $USR -c "find $ARCH1 -name compressed -prune -o -type f -atime 1 -exec mv {} /global/ORA_BACKUP/archlogs/$INSTANCE/ \;"
echo Return code: $?
date '+End: %H:%M:%S'
echo "Current Disc usage ...."
df -k|grep ORA
df -k|grep $INSTANCE_REDO


Codice:
 
/root/scripts>./ARC-PURGE.sh ESPOS espos 2>&1 mailx -s "ESPOS Archivelog Purge" babu.knb@gmail.com
User check OK
Wrong number of Parameters or no Parameter have been given. USAGE: arc_purge.sh ESPOS/FPRINT espos/fprint

Ho qui di seguito messaggio di errore. Please advice me quello che era il problema?
  #2 (permalink)  
Old 11-22-2008
Moshe fritto moshe fried is offline
Utente Registrato
  
 

Iscriviti Data: febbraio 2007
Località: Israele
Interventi: 24
provare se [$ #! \u003d 2] invece di if [! $ # \u003d 2]
  #3 (permalink)  
Old 11-22-2008
rc7 rc7 is offline
Utente Registrato
  
 

Join Date: Aug 2008
Interventi: 4
Bash è dotato di un operatore in -ne per intero il confronto. Vorrei ri-scrivere il codice per verificare il numero di argomenti come:
if [$ #-ne 2]; poi
Closed Thread

Segnalibri

Tag
script di shell, shell scripting, unix script, basi di scripting unix

Thread Tools Cerca in questo Thread
Cerca in questo Thread:

Ricerca Avanzata
Modalità di visualizzazione Vota questo thread
Vota questo thread:

Distacco regolamento
Tu non può post nuovo thread
Tu non può inviare una risposta
Tu non può postare allegati
Tu non può modificare i tuoi post

BB codice è Su
Smilies sono Su
[IMG] codice Su
Codice HTML è Chiuso
Trackbacks sono Su
Pingbacks sono Su
Refbacks sono Su




Tutti gli orari sono GMT -4. La data di oggi è 11:48 PM.


Powered by: vBulletin, Copyright © 2000 - 2006, Jelsoft Enterprises Limited. Traduzioni Powered by .
vBCredits v1.4 Copyright © 2007 - 2008, PixelFX Studios
UNIX e Linux Forum Content Copyright © 1993-2009. Tutti i diritti Reserved.Ad di gestione da RedTyger

Contenuti pertinenti URL da vBSEO 3.2.0