The UNIX and Linux Forums  

Go Back   O UNIX e Linux Forum > Top Fóruns > Programação Shell Script e
.
google unix.com



Programação Shell Script e Post perguntas sobre ksh, CSH, SH, BASH, Perl, PHP, SED, Awk e outros scripts shell e shell scripts línguas aqui.

Mais UNIX e Linux Fórum Tópicos Você pode achar Helpfull
Fio Thread Starter Fórum Respostas Última postagem
Problema no shell script arnie_nits Programação Shell Script e 1 12-12-2007 10:13
Shell script problema shashi_kiran_v UNIX para Dummies Perguntas & Respostas 5 01-10-2007 11:49
shell script problema djt0506 UNIX para Dummies Perguntas & Respostas 2 12-07-2005 11:29
Problema com shell script zylwyz Programação Shell Script e 2 06-29-2005 02:01
Problema com shell script nattynatty Programação Shell Script e 4 04-09-2002 04:30

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 Pesquisar este Thread Rate Thread Display Modes
  #1 (permalink)  
Old 11-18-2008
babu.knb babu.knb is offline
Usuário
  
 

Join Date: Sep 2008
Localização: Índia
Posts: 7
Problema no shell script

Código:
 
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
Código:
 
/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
Tenho abaixo mensagem de erro. Por favor, me parecer que foi o problema?
  #2 (permalink)  
Old 11-22-2008
Moshe frito moshe fried is offline
Usuário
  
 

Join Date: Feb 2007
Localização: Israel
Lugares: 24
try if [$ #! \u003d 2], em vez de se [! $ # \u003d 2]
  #3 (permalink)  
Old 11-22-2008
rc7 rc7 is offline
Usuário
  
 

Join Date: Aug 2008
Posts: 4
Bash tem um built-in operador -ne inteiro para a comparação. Gostaria de re-escrever o código para verificar número de argumentos como:
if [$ #-ne 2]; então
Closed Thread

Marcadores

Tags
shell script, shell script, unix script, unix script básico

Thread Tools Pesquisar este Thread
Pesquisar este Thread:

Pesquisa Avançada
Display Modes Esta taxa Thread
Esta taxa Thread:

Destacamento Regimento
Você não pode postar novas threads
Você não pode postar respostas
Você não pode postar anexos
Você não pode editar suas postagens

BB code é Ligado
Smilies são Ligado
[IMG] código é Ligado
Código HTML é Desligado
Trackbacks são Ligado
Pingbacks são Ligado
Refbacks são Ligado




Todos os horários são GMT -4. A hora é agora 04:16.


Powered by: vBulletinCopyright © 2000 - 2006, Jelsoft Enterprises Limited. Língua Traduções Powered by .
vBCredits v1.4 Copyright © 2007 - 2008, PixelFX Studios
O UNIX e Linux Fóruns Content Copyright © 1993-2009. Todos os Direitos Reserved.Ad Gestão por RedTyger

Content Relevant URLs por vBSEO 3.2.0