Linux/Unix Shell Scripting - copiasa

 
Vista:

copiasa

Publicado por Gonda (1 intervención) el 31/07/2025 00:54:48
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
# Alias Estandar:
# cdsb=/Gonda/murray/stage/bms
# cdsbb=/Gonda/murray/stage/binbtch
# cdsbt=/Gonda/murray/stage/bincics
# cdsc=/Gonda/murray/stage/cpy
# cdsf=/Gonda/murray/stage/fic
# cdsj=/Gonda/murray/stage/jcl
# cdsl=/Gonda/murray/stage/log
# cdsm=/Gonda/murray/stage/map
# cdsr=/Gonda/murray/stage/ref
# cdss=/Gonda/murray/stage/src
# cdst=/Gonda/murray/stage/tmp
# cdsu=/Gonda/murray/stage/jobset
# cdsx=/Gonda/murray/stage/outils
# Seteo de colores
# Ejemplos
cdmc=${G7_VERSION}/${G7_ENV}/site/smc
UID='echo ${who am i}'
AT2=/${G7_VERSION}/${G7_ENV}/site
USR=/data/atlas2ar/desarrollo/${UID}
PRD=/data/atlas2ar/PaseProd
LOG=/data/atlas2ar/desarrollo/${UID}/fic/PASECOMP.log
OPC1_1="ENVIAR DE ${AT2} A ${USR}"
OPC1_2="ENVIAR DE ${USR} A ${AT2}"
OPC1_3="ENVIAR DE ${USR} A ${PRD}"
opc1=""
while [ "$opc1" != "0" ]
do
clear
echo -e ""
echo -e "${G7_ENV} - Pasaje de componentes:"
echo -e ""
echo -e "1 - De Componentes Sitio a Biblioteca Programador"
echo -e "2 - De Biblioteca Programador a Componentes Sitio"
echo -e "3 - De Biblioteca Programador a Pasaje a Produccion"
echo -e ""
read opc1?"Opcion [0-Salir] : "
if [[ $opc1 -eq 0 ]] then
   exit
else
   echo -e ""
   echo -e "1 - Pasar un BOX"
   echo -e "2 - Pasar un JCL"
   echo -e "3 - Pasar un SRC"
   echo -e "4 - Pasar un BIN"
   echo -e "5 - Pasar un SMC"
   echo -e ""
   read opc2?"Opcion [0-Cancelar] : "
   if [[ $opc2 -ne 0 ]] then
      read ID?"Nombre del componente... : "
      case "$opc2" in
      1) TIPO="jobset" ;;
      2) TIPO="jcl" ;;
      3) TIPO="src" ;;
      4) TIPO="binbtch" ;;
      5) TIPO="smc" ;;
      esac
      case "$opc1" in
      1) TIT="PASAJE DE BIBLIOTECA SITIO A BIBLIOTECA DEL PROGRAMADOR" ; CMD="cp $AT2/$TIPO/$ID $USR/$TIPO/$ID" ; VER="ls -ltr $USR/$TIPO/$ID" ;;
      2) TIT="PASAJE DE BIBLIOTECA DE PROGRAMADOR A BIBLIOTECA SITIO" ; CMD="cp $USR/$TIPO/$ID $AT2/$TIPO/$ID" ; VER="ls -ltr $AT2/$TIPO/$ID" ;;
      3) TIT="PASAJE DE BIBLIOTECA DEL PROGRAMADOR A PRODUCCION" ; CMD="cp $USR/$TIPO/$ID $PRD/$TIPO/$ID" ; VER="ls -ltr $PRD/$TIPO/$ID" ;;
      esac
      echo -e ""
      read OK?"Confirma el pasaje (S/N) : "
      OK=`echo $OK | tr a-z A-Z`
      echo -e ""
      if [[ "$OK" = "S" ]] then
         $CMD
         if [[ $? -eq 0 ]] then
            echo -e "${VERDE}OK - ${TIT}${RESET}"
            echo -e "$(date) - PASAJE OK - $CMD" >> $LOG
         else
            echo -e "${ROJO}KO - ${TIT}${RESET}"
            echo -e "$(date) - PASAJE KO - $CMD" >> $LOG
         fi
         read stop?"Pulse cualquier tecla para continuar..."
      else
         echo -e "Proceso cancelado..."
         read stop?"Pulse cualquier tecla para continuar..."
      fi
   fi
fi
opc=99
done
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder

copiasa

Publicado por LolaTon (1 intervención) el 31/07/2025 07:24:28
este esel mejor

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
#!/bin/ksh
####################################################################
export USER=`echo ${who am i}`
export Fechita=`date +'%m%d'`
export Fecha=`date +'%Y%m%d'`
export SITE=/Gonda/murray/stage/
export ShellPasaje=$cdsj/DATAPAS.$USER.$MES.sh
export CANTIDAD=0
 
export PASEPROD
export COMPONENTE=
export DESTINO=
export DRFINAL=
export SVUSER
export BUMACHINE
export IDSHELDESA
export IDSHELSTAGE
export DIRCDSL
 
 
####################################################################
 
####################################################################
CapturaShellPasaje {
   Detalle=`cat $ShellPasaje`
}
####################################################################
 
####################################################################
QueresEjecutar {
     echo -e "====[PASE A STEGING - YA ESTA GENERADO EL SCRIPT]====[$Fecha]====="
     MostrarCargados
     read ACCION?" DESEA EJECUTAR EL PASE?[S/N]: "
     if [[ -z "$ACCION" ]]; then
         echo "NO SE GENERARA EJECUTARA EL PASE... BYE!"
         sleep 1
     else
         ACCION=`echo "$ACCION" | tr a-z A-Z`
         if [[ "$ACCION"!="S" ]]; then
            EjecutaPasaje
         fi
     fi
}
####################################################################
 
####################################################################
GeneraScriptPase {
     if test -s "$ShellPasaje"; then
        while IFS=: read -r nombre destino paseprod; do
           echo "scp $nombre  $SVUSER@BUMACHINE:$destino" >> $IDSHELDESA
           echo "scp $nombre  $SVUSER@BUMACHINE:$paseprod" >> $IDSHELSTAGE
        done < "$ShellPasaje"
        echo "scp $IDSHELSTAGE  $SVUSER@BUMACHINE:$DIRJCL" >> $IDSHELDESA
     fi
}
####################################################################
 
####################################################################
EjecutaPasaje {
     if test -s "$ShellPasaje"; then
        sh $IDSHELDESA
        mv $IDSHELDESA   $DIRCDSL
     fi
}
####################################################################
 
####################################################################
MostrarCargados {
     export count=0
     if test -s "$ShellPasaje"; then
        while IFS=: read -r nombre destino paseprod; do
           ((count++))    # Increment count
           echo "$count  $nombre"
           CANTIDAD=$count
        done < "$ShellPasaje"
     else
        count=1
     fi
     for (( i=$count; i<=19; i++ )); do
         echo " "
     done
     unset count
}
####################################################################
 
####################################################################
AgregaComponente {
     echo "$COMPONENTE : $DESTINO : $DRFINAL" >>  $ShellPasaje
}
####################################################################
 
####################################################################
VerificaTipoyCarga {
     export FERROR="OK"
     if test -s "$SITE/src/$OBJETO"; then
        export COMPONENTE=$SITE/src/$OBJETO
        export DESTINO=$SITE/src/
        export DRFINAL=$PASEPROD/src/
        AgregaComponente
     else
        if test -s "$SITE/bms/$OBJETO"; then
           export COMPONENTE=$SITE/bms/$OBJETO
           export DESTINO=$SITE/bms/
           export DRFINAL=$PASEPROD/bms/
           AgregaComponente
        else
           if test -s "$SITE/jcl/$OBJETO"; then
              export COMPONENTE=$SITE/jcl/$OBJETO
              export DESTINO=$SITE/jcl/
              export DRFINAL=$PASEPROD/jcl/
              AgregaComponente
           else
              if test -s "$SITE/jobset/$OBJETO"; then
                 export COMPONENTE=$SITE/jobset/$OBJETO
                 export DESTINO=$SITE/jobset/
                 export DRFINAL=$PASEPROD/jobset/
                 AgregaComponente
              else
                 if test -s "$SITE/bincics/$OBJETO"; then
                    export COMPONENTE=$SITE/bincics/$OBJETO
                    export DESTINO=$SITE/bincics/
                    export DRFINAL=$PASEPROD/bincics/
                    AgregaComponente
                 else
                    if test -s "$SITE/binbtch/$OBJETO"; then
                       export COMPONENTE=$SITE/binbtch/$OBJETO
                       export DESTINO=$SITE/binbtch/
                       export DRFINAL=$PASEPROD/binbtch/
                       AgregaComponente
                    else
                       if test -s "$SITE/cpy/$OBJETO"; then
                          export COMPONENTE=$SITE/cpy/$OBJETO
                          export DESTINO=$SITE/cpy/
                          export DRFINAL=$PASEPROD/cpy/
                          AgregaComponente
                       else
                          if test -s "$SITE/map/$OBJETO"; then
                             export COMPONENTE=$SITE/map/$OBJETO
                             export DESTINO=$SITE/map/
                             export DRFINAL=$PASEPROD/map/
                             AgregaComponente
                          else
                             if test -s "$DATA/fic/$OBJETO"; then
                                export COMPONENTE=$DATA/fic/$OBJETO
                                export DESTINO=$DATA/fic/
                                export DRFINAL=$DATA/fic/
                                AgregaComponente
                             else
                                export FERROR="Componente [$OBJETO ] NO FUE ENCONTRADO"
                             fi
                          fi
                       fi
                    fi
                 fi
              fi
           fi
        fi
     fi
}
####################################################################
# cdmc=${G7_VERSION}/${G7_ENV}/site/smc
####################################################################
UID='echo ${who am i}'
 
rm -f $ShellPasaje
touch $ShellPasaje
export ACCION=`echo "nosalgo" | tr a-z A-Z`
while [[ "$ACCION"!="SALIR" ]]
do
     clear
     export OBJETO=""
     echo -e "=========[PASE DE COMPONENTES A STEGING]========[$Fecha]=========="
     MostrarCargados
     read OBJETO?"  Ingrese el nombre exacto del componente[]:"
     if [[ -z "$OBJETO" ]]; then
         echo "DEBE INGRESAR EL NOMBRE DEL COMPONENTE"
         sleep 1
     else
         export ACCION=`echo $OBJETO | tr a-z A-Z`
         if [[ "$ACCION"!="SALIR" ]]; then
             VerificaTipoyCarga
             if [[ "$FERROR"!="OK" ]]; then
                 echo "Error :$FERROR"
                 sleep 2
             fi
         fi
     fi
     unset OBJETO
done
if [[ $CANTIDAD -gt 0 ]]; then
     export EJECUTAR=0
     echo -e "=======[ESTA ES LA LISTA A PASAR A STEGING]======[$Fecha]========="
     MostrarCargados
     read ACCION?" DESEA GENERAR EL SCRIPT FINAL?[S/N]: "
     if [[ -z "$ACCION" ]]; then
         echo "NO SE GENERARA EL SCRIPT DE PASE... BYE!"
         sleep 1
     else
         ACCION=`echo "$ACCION" | tr a-z A-Z`
         if [[ "$ACCION"!="S" ]]; then
            GeneraScriptPase
            QueresEjecutar
         fi
     fi
fi
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar