elhacker.net cabecera Bienvenido(a), Visitante. Por favor Ingresar o Registrarse
¿Perdiste tu email de activación?.

 

 


Tema destacado: Arreglado, de nuevo, el registro del warzone (wargame) de EHN


+  Foro de elhacker.net
|-+  Programación
| |-+  Scripting
| | |-+  Que función cumple este script?
0 Usuarios y 1 Visitante están viendo este tema.
Páginas: [1] Ir Abajo Respuesta Imprimir
Autor Tema: Que función cumple este script?  (Leído 1,922 veces)
lorden

Desconectado Desconectado

Mensajes: 3


Ver Perfil
Que función cumple este script?
« en: 12 Junio 2017, 04:15 am »

Buenos dia gente! -Necesito saber para que sirve este script ya que yo no puedo comprender que hace.
El script pertenece al paquete de aptitude y el script es el aptitude-run-state-bundle.

Código
  1. #!/bin/bash
  2.  
  3. NO_CLEAN=0
  4. STATEDIR=0
  5. UNPACK_ONLY=0
  6. HELP=0
  7. APPEND=1
  8.  
  9. DONE=0
  10. while [ $DONE = 0 ]
  11. do
  12.  case "$1" in
  13.      --append-args )
  14.          APPEND=1
  15.          shift
  16.          ;;
  17.      --help )
  18.          HELP=1
  19.          shift
  20.          ;;
  21.      --no-clean )
  22.          NO_CLEAN=1
  23.          shift
  24.          ;;
  25.      --prepend-args )
  26.          APPEND=0
  27.          shift
  28.          ;;
  29.      --really-clean )
  30.          NO_CLEAN=0
  31.          shift
  32.              ;;
  33.      --statedir )
  34.          STATEDIR=1
  35.          NO_CLEAN=1
  36.          shift
  37.          ;;
  38.      --unpack )
  39.          UNPACK_ONLY=1
  40.          shift
  41.          ;;
  42.      * )
  43.          DONE=1
  44.          ;;
  45.  esac
  46. done
  47.  
  48. if ( [ $UNPACK_ONLY = 0 ] && [ "$#" -lt 1 ] ) ||
  49.   ( [ $UNPACK_ONLY = 1 ] && [ "$#" -ne 1 ] ) ||
  50.   [ $HELP = 1 ]
  51. then
  52.    echo "Usage: $0 [options] <input-file> [<program> [arguments ...]]"
  53.    echo
  54.    echo "This command will unpack the given archive of aptitude state"
  55.    echo "information, then invoke the given program with the given"
  56.    echo "list of arguments, passing appropriate -o options to cause"
  57.    echo "aptitude to use the contents of that archive as its global"
  58.    echo "data store."
  59.    echo
  60.    echo "Options:"
  61.    echo "  --append-args    Place the generated arguments at the end of"
  62.    echo "                   the command line (default)."
  63.     echo "  --help           Display this message and exit."
  64.    echo "  --no-clean       Do not remove the temporary directory after"
  65.    echo "                   invoking aptitude."
  66.    echo "  --prepend-args   Place the generated arguments at the beginning"
  67.    echo "                   of the command line."
  68.    echo "  --really-clean   Remove the state directory, even if --statedir"
  69.    echo "                   was passed as an argument."
  70.    echo "  --statedir       The <input-file> is an unpacked aptitude bundle,"
  71.    echo "                   not a bundle file; implicitly sets --no-clean."
  72.    echo "  --unpack         Just unpack the <input-file>, don't run aptitude."
  73.    exit 1
  74. fi
  75.  
  76. INPUTFILE="$1"
  77. shift
  78.  
  79. if [ "$#" -lt 1 ]
  80. then
  81.    PROGRAM=aptitude
  82. else
  83.    PROGRAM="$1"
  84.    shift
  85. fi
  86.  
  87. if [ $STATEDIR = 0 ]
  88. then
  89.    tempdir=$(mktemp -p ${TMPDIR:-/tmp} -d aptitudebug.XXXXXXXXX) || exit 1
  90.    if [ -z "$tempdir" ]
  91.        then
  92.        exit 1
  93.    fi
  94. else
  95.    tempdir=$INPUTFILE
  96. fi
  97.  
  98. trap '
  99. if [ $NO_CLEAN = 1 ]
  100. then echo "Leaving final state in $tempdir"
  101. else echo "Removing $tempdir"; rm -fr $tempdir
  102. fi' 0
  103.  
  104. if [ $STATEDIR = 0 ]
  105. then
  106.    if [ -d "$INPUTFILE" ]
  107.    then
  108.        echo "Can't use $INPUTFILE as the input bundle: it's a directory."
  109.        exit 1
  110.    fi
  111.    if ! [ -f "$INPUTFILE" ]
  112.    then
  113.        echo "Can't use $INPUTFILE as the input bundle: file not found."
  114.        exit 1
  115.    fi
  116.  
  117.    tar -C "$tempdir" -xf "$INPUTFILE" || exit 1
  118. fi
  119.  
  120. if [ $UNPACK_ONLY = 1 ]
  121. then
  122.    exit 0
  123. fi
  124. if [ "$APPEND" = 1 ]
  125. then
  126.    "$PROGRAM" "$@" -o "Dir=$tempdir" -o "Dir::State::status=$tempdir/var/lib/dpkg/status"
  127. else
  128.  
  129.    "$PROGRAM" -o "Dir=$tempdir" -o "Dir::State::status=$tempdir/var/lib/dpkg/status" "$@"
  130. fi
  131.  
  132.  


« Última modificación: 12 Junio 2017, 05:11 am por Eleкtro » En línea

engel lex
Moderador Global
***
Desconectado Desconectado

Mensajes: 15.514



Ver Perfil
Re: Que función cumple este script?
« Respuesta #1 en: 12 Junio 2017, 04:18 am »

basicmante todo es expresando al usuario lo que hará (echo)

al final

Código:
"$PROGRAM" "$@" -o "Dir=$tempdir" -o "Dir::State::status=$tempdir/var/lib/dpkg/status"

busca donde se asingan esas variables, simplemente corre un programa con argumentos...



En línea

El problema con la sociedad actualmente radica en que todos creen que tienen el derecho de tener una opinión, y que esa opinión sea validada por todos, cuando lo correcto es que todos tengan derecho a una opinión, siempre y cuando esa opinión pueda ser ignorada, cuestionada, e incluso ser sujeta a burla, particularmente cuando no tiene sentido alguno.
Páginas: [1] Ir Arriba Respuesta Imprimir 

Ir a:  

Mensajes similares
Asunto Iniciado por Respuestas Vistas Último mensaje
Como cambiar la función de un script en PHP??
PHP
shamaka 1 2,485 Último mensaje 6 Diciembre 2010, 12:32 pm
por seele
[C] ayuda, programa compila bien pero no cumple la funcion (solucionado)
Programación C/C++
xiruko 6 3,453 Último mensaje 15 Abril 2012, 23:48 pm
por xiruko
LUA SCRIPT - BOTONES CON DOBLE FUNCIÓN
Scripting
CADIAR 1 4,127 Último mensaje 29 Marzo 2014, 15:42 pm
por Eleкtro
WAP2 - Aviso Legal - Powered by SMF 1.1.21 | SMF © 2006-2008, Simple Machines