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

 

 


Tema destacado: ¿Eres nuevo? ¿Tienes dudas acerca del funcionamiento de la comunidad? Lee las Reglas Generales


+  Foro de elhacker.net
|-+  Programación
| |-+  Scripting
| | |-+  [BASH] Script instalación de módulos Perl
0 Usuarios y 1 Visitante están viendo este tema.
Páginas: [1] Ir Abajo Respuesta Imprimir
Autor Tema: [BASH] Script instalación de módulos Perl  (Leído 2,439 veces)
leogtz
. . .. ... ..... ........ ............. .....................
Colaborador
***
Desconectado Desconectado

Mensajes: 3.069


/^$/


Ver Perfil WWW
[BASH] Script instalación de módulos Perl
« en: 12 Enero 2011, 01:39 am »

Hola, acabo de hacer este script para la instalación de módulos en Perl.

El script checa si el módulo está instalado, sino lo está pregunta si se quiere instalar dicho módulo, si sí se quiere instalar, descarga el módulo desde CPAN y lo instala normalmente.


Código
  1. #!/bin/bash
  2. # Leo Gutiérrez R. leorocko13@hotmail.com
  3. [ ${UID} != 0 ] && {
  4. echo -e "Se requieren privilegios de Root";
  5. exit 1;
  6. }
  7.  
  8. MODULE_NAME="Math::BigInt::Random";
  9. URL_MODULE="http://search.cpan.org/CPAN/authors/id/B/BI/BILLH/Math-BigInt-Random-0.04.tar.gz";
  10. PATH_MODULE="Math-BigInt-Random-0.04.tar.gz";
  11.  
  12. perl -M${MODULE_NAME} -e 1 2> /dev/null || {
  13. echo -e "\aEl módulo no existe\n¿Desea instalarlo:?";
  14. opciones="Sí No";
  15. select opt in ${opciones}
  16. do
  17. if [ "${opt}" = "Sí" ]
  18. then
  19.  
  20. wget "${URL_MODULE}";
  21. tar zxvf "${PATH_MODULE}";
  22. cd "${PATH_MODULE%\.tar.gz}" 2> /dev/null || {
  23. echo -e "\aError abriendo directorio ${1%%.*}";
  24. exit 1;
  25. }
  26. perl Makefile.PL
  27. make
  28. make test
  29. make install
  30. exit 0;
  31.  
  32. elif [ "${opt}" = "No" ]
  33. then
  34.  
  35. echo -e "\aLa instalación del módulo es necesaria";
  36. exit 1;
  37.  
  38. fi
  39. done
  40. }
  41.  

Código
  1. leo@leo-desktop:~/Escritorio$ sudo bash shell.sh
  2. El módulo no existe
  3. ¿Desea instalarlo:?
  4. 1)
  5. 2) No
  6. #? 1
  7. --2011-01-11 17:30:26--  http://search.cpan.org/CPAN/authors/id/B/BI/BILLH/Math-BigInt-Random-0.04.tar.gz
  8. Resolviendo search.cpan.org... 207.115.101.144, 194.106.223.155
  9. Conectando a search.cpan.org|207.115.101.144|:80... conectado.
  10. Petición HTTP enviada, esperando respuesta... 302 Found
  11. Ubicación: http://www.msg.com.mx/CPAN/authors/id/B/BI/BILLH/Math-BigInt-Random-0.04.tar.gz [siguiente]
  12. --2011-01-11 17:30:26--  http://www.msg.com.mx/CPAN/authors/id/B/BI/BILLH/Math-BigInt-Random-0.04.tar.gz
  13. Resolviendo www.msg.com.mx... 200.33.54.1
  14. Conectando a www.msg.com.mx|200.33.54.1|:80... conectado.
  15. Petición HTTP enviada, esperando respuesta... 200 OK
  16. Longitud: 11569 (11K) [application/x-tar]
  17. Guardando en: «Math-BigInt-Random-0.04.tar.gz»
  18.  
  19. 100%[========================================================================================================================================>] 11,569      --.-K/s   en 0.1s    
  20.  
  21. 2011-01-11 17:30:26 (108 KB/s) - «Math-BigInt-Random-0.04.tar.gz» guardado [11569/11569]
  22.  
  23. Math-BigInt-Random-0.04/
  24. Math-BigInt-Random-0.04/Changes
  25. Math-BigInt-Random-0.04/lib/
  26. Math-BigInt-Random-0.04/lib/Math/
  27. Math-BigInt-Random-0.04/lib/Math/BigInt/
  28. Math-BigInt-Random-0.04/lib/Math/BigInt/Random.pm
  29. Math-BigInt-Random-0.04/LICENSE
  30. Math-BigInt-Random-0.04/Makefile.PL
  31. Math-BigInt-Random-0.04/MANIFEST
  32. Math-BigInt-Random-0.04/META.yml
  33. Math-BigInt-Random-0.04/README
  34. Math-BigInt-Random-0.04/t/
  35. Math-BigInt-Random-0.04/t/01_test.t
  36. Math-BigInt-Random-0.04/t/02_pod.t
  37. Math-BigInt-Random-0.04/t/03_pod_coverage.t
  38. Math-BigInt-Random-0.04/Todo
  39. Checking if your kit is complete...
  40. Looks good
  41. Writing Makefile for Math::BigInt::Random
  42. cp lib/Math/BigInt/Random.pm blib/lib/Math/BigInt/Random.pm
  43. Manifying blib/man3/Math::BigInt::Random.3
  44. PERL_DL_NONLAZY=1 /usr/local/bin/perl "-MExtUtils::Command::MM" "-e" "test_harness(0, 'blib/lib', 'blib/arch')" t/*.t
  45. t/01_test.t .......... ok    
  46. t/02_pod.t ........... ok  
  47. t/03_pod_coverage.t .. skipped: Test::Pod::Coverage required for testing POD coverage
  48. All tests successful.
  49. Files=3, Tests=15,  3 wallclock secs ( 0.04 usr  0.02 sys +  0.35 cusr  0.08 csys =  0.49 CPU)
  50. Result: PASS
  51. Manifying blib/man3/Math::BigInt::Random.3
  52. Installing /usr/local/lib/perl5/site_perl/5.12.0/Math/BigInt/Random.pm
  53. Installing /usr/local/share/man/man3/Math::BigInt::Random.3
  54. Appending installation info to /usr/local/lib/perl5/5.12.0/i686-linux/perllocal.pod
  55.  

Incluso podríamos trabajar con un archivo externo en donde se pongan los módulos a instalar.


En línea

Código
  1. (( 1 / 0 )) &> /dev/null || {
  2. echo -e "stderrrrrrrrrrrrrrrrrrr";
  3. }
  4.  
http://leonardogtzr.wordpress.com/
leogutierrezramirez@gmail.com
m1kh41l

Desconectado Desconectado

Mensajes: 26



Ver Perfil
Re: [BASH] Script instalación de módulos Perl
« Respuesta #1 en: 14 Enero 2011, 04:35 am »

muy bien


En línea

no te hagas el filósofo en la firma, demuéstralo...
Páginas: [1] Ir Arriba Respuesta Imprimir 

Ir a:  

Mensajes similares
Asunto Iniciado por Respuestas Vistas Último mensaje
Instalación de Librerías / Modulos en Perl
Scripting
Tec-n0x 2 4,961 Último mensaje 10 Agosto 2008, 02:19 am
por Tec-n0x
script bash (ubuntu): Parar un proceso sin salir del script (SOLUCIONADO)
Scripting
moikano→@ 6 11,062 Último mensaje 28 Octubre 2010, 15:48 pm
por moikano→@
[Bash script] equivalente de goto en batch para bash (SOLUCIONADO)
Scripting
moikano→@ 4 16,119 Último mensaje 4 Noviembre 2010, 15:58 pm
por moikano→@
[AYUDA] quien sabe como instalar los modulos en perl
Scripting
Rankor15 0 1,424 Último mensaje 7 Octubre 2012, 18:52 pm
por Rankor15
Ayuda con script (en bash, python o perl)
Scripting
akakariko 4 2,537 Último mensaje 28 Septiembre 2017, 20:36 pm
por Slava_TZD
WAP2 - Aviso Legal - Powered by SMF 1.1.21 | SMF © 2006-2008, Simple Machines