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

 

 


Tema destacado: Los 10 CVE más críticos (peligrosos) de 2020


+  Foro de elhacker.net
|-+  Programación
| |-+  Scripting
| | |-+  Dudas con con partes de mi script [Bash]
0 Usuarios y 1 Visitante están viendo este tema.
Páginas: [1] Ir Abajo Respuesta Imprimir
Autor Tema: Dudas con con partes de mi script [Bash]  (Leído 2,792 veces)
Afsoon

Desconectado Desconectado

Mensajes: 130


Ver Perfil
Dudas con con partes de mi script [Bash]
« en: 30 Abril 2010, 19:56 pm »

Hola buenas, estoy haciendo un script para ubuntu para la version 10.04, la gente sabra que ya ha salido la ultima version, bien decidi probar el script, pos hay partes que no me furulan y tenian que ser las partes mas importantes del programa, ire poniendo las partes de los que no me funcionan


Código
  1. #!/bin/bash
  2.  
  3. pog=`zenity --title="P.A.U" --text="Seleccione los programas que desee instalar" --width="1000" --height="900" \
  4. --list --column="Select" --column="Opciones" \
  5. --checklist TRUE "Wine" TRUE "Gimp"  \
  6. TRUE "Pidgin" TRUE "Chromium" TRUE "Compizfusion" TRUE "AWN"  TRUE "Docky"  TRUE "GnomeDo"  TRUE "Inkscape"  \
  7. TRUE "Eclipse"  TRUE "Netbeans"  TRUE "Vim" TRUE "Skype" TRUE "K3B"  TRUE "Mozilla Thunderbird" TRUE "Amule" \
  8. TRUE "Tucan Manager" TRUE "Vlc" TRUE "Comix" FALSE "K3b.Con las librerias de KDE" TRUE "JDownloader" \
  9. TRUE "Amarok" TRUE "Atool" TRUE "Guake" TRUE "Emesene" TRUE "Gparted" TRUE "Google Chrome" TRUE "Virtualbox" \
  10. TRUE "Hoz"  TRUE "Dvd::rip" TRUE "Avidemux" FALSE "Yakuake.Para KDE" TRUE "Alltray"`
  11. if [ $? -eq 0 ]
  12. then
  13. for i in $pog ; do
  14. echo ""
  15. echo "Has elegido la opcion $i"
  16. if [ "$i" = "Wine" ]
  17. then
  18. echo "chekpoint"
  19. sudo apt-get -y install wine
  20. clear
  21. fi
  22. if [ "$i" = "Gimp" ]
  23. then
  24. echo "checkpoint"
  25. sudo sh -cecho "deb http://ppa.launchpad.net/matthaeus123/mrw-gimp-svn/ubuntu lucid main" >> /etc/apt/sources.list” && sudo apt-key adv –recv-keys –keyserver keyserver.ubuntu.com 405A15CB && sudo apt-get update && sudo apt-get -y install gimp
  26. clear
  27. fi
  28. if [ $i = "Pidgin" ]
  29. then
  30. sudo add-apt-repository ppa:pidgin-developers && sudo apt-get update && sudo aptitude -y install pidgin
  31. clear
  32. fi
  33. if [ $i = "Chromium" ]
  34. then
  35. sudo add-apt-repository ppa:chromium-daily/ppa && sudo apt-get update && sudo apt-get -y install chromium-browser chromium-browser-l10n
  36. clear
  37. fi
  38. if [ $i = "Compizfusion" ]
  39. then
  40. sudo add-apt-repository ppa:compiz && sudo apt-get update && sudo aptitude -y install simple-ccsm compizconfig-settings-manager emerald && install fusion-icon
  41. clear
  42. fi
  43. if [ $i = "AWN" ]
  44. then
  45. sudo apt-get update && sudo apt-get -y install avant-window-navigator awn-extras-applets
  46. clear
  47. fi
  48. if [ $i = "Docky" ]
  49. then
  50. sudo add-apt-repository ppa:ricotz/testing && sudo apt-get update && sudo apt-get -y install docky
  51. clear
  52. fi
  53. if [ $i = "GnomeDo" ]
  54. then
  55. sudo add-apt-repository ppa:do-core && sudo apt-get update && sudo apt-get -y install gnome-do gnome-do-docklets gnome-do-plugins
  56. clear
  57. fi
  58. if [ $i = "Inkscape" ]
  59. then
  60. sudo aptitude -y install inkscape
  61. clear
  62. fi
  63. if [ $i = "Eclipse" ]
  64. then
  65. sudo aptitude -y install eclipse
  66. clear
  67. fi
  68. if [ $i = "Netbeans" ]
  69. then
  70. sudo aptitude -y install netbeans
  71. clear
  72. fi
  73. if [ $i = "Vim" ]
  74. then
  75. sudo aptitude -y install vim
  76. clear
  77. fi
  78. if [ $i = "Skype" ]
  79. then
  80. cd /tmp      
  81. wget http://download.skype.com/linux/skype-ubuntu-intrepid_2.1.0.81-1_${arch}.deb                          
  82. sudo dpkg -i --force-all skype-ubuntu-intrepid_2.1.0.81-1_${arch}.deb                          
  83. sudo apt-get -y --force-yes install -f -y                          
  84. rm skype-ubuntu-intrepid_2.1.0.81-1_${arch}.deb
  85. clear
  86. fi
  87. if [ $i = "K3B" ]
  88. then
  89. sudo aptitude -y install k3b
  90. clear
  91. fi
  92. if [ $i = "Mozilla Thunderbird" ]
  93. then
  94. sudo aptitude -y install  mozilla-thunderbird thunderbird-locale-es-es
  95. clear
  96. fi
  97. if [ $i  = "Amule" ]
  98. then
  99. sudo aptitude -y install amule
  100. clear
  101. fi
  102. if [ $i = "Tucan Manager" ]
  103. then
  104. sudo aptitude -y install tucan
  105. clear
  106. fi
  107. if [ $i = "Vlc" ]
  108. then
  109. sudo add-apt-repository ppa:c-korn && sudo apt-get update && sudo apt-get -y install vlc
  110. clear
  111. fi
  112. if [ $i = "Comix" ]
  113. then
  114. sudo aptitude -y install comix
  115. clear
  116. fi
  117. if [ $i = "K3b.Con las librerias de KDE" ]
  118. then
  119. sudo aptitude install k3b && sudo aptitude -y install kde-i18n-es k3b-i18n
  120. clear
  121. elif [ $i = "JDownloader" ]
  122. then
  123. wget http://212.117.163.148/jd.sh
  124. chmod +x jd.sh
  125. sh jd.sh
  126. java -jar ~/.jd/JDownloader.jar
  127. clear
  128. fi
  129. if [ $i = "Amarok" ]
  130. then
  131. sudo add-apt-repository ppa:kubuntu-ppa/backports && sudo apt-get update && sudo apt-get -y install amarok
  132. clear
  133. fi
  134. if [ $i = "Atool" ]
  135. then
  136. sudo aptitude -y install atool
  137. clear
  138. fi
  139. if [ $i = "Guake" ]
  140. then
  141. sudo apt-get -y install guake
  142. clear
  143. fi
  144. if [ $i = "Emesene" ]
  145. then
  146. sudo apt-get -y install emesene
  147. clear
  148. fi
  149. if [ $i = "Gparted" ]
  150. then
  151. sudo aptitude -y install gparted
  152. clear
  153. fi
  154. if [ $i = "Google Chrome" ]
  155. then
  156. sudo add-apt-key ppa:chromium-daily/ppa && sudo apt-get update && sudo apt-get -y install chromium-browser
  157. clear
  158. fi
  159. if [ $i = "Virtualbox" ]
  160. then
  161. cd /etc/apt/
  162. echo "deb http://download.virtualbox.org/virtualbox/debian karmic non-free" >> sources.list
  163. wget -q http://download.virtualbox.org/virtualbox/debian/sun_vbox.asc -O- | sudo apt-key add -
  164. if [ "i686" = `uname -m` ]
  165. then
  166. cd /home/$USER/
  167. wget http://download.virtualbox.org/virtualbox/3.1.6/virtualbox-3.1_3.1.6-59338_Ubuntu_karmic_${arch}.deb
  168. dpkg -i --force-all virtualbox-3.1_3.1.6-59338_Ubuntu_karmic_${arch}.deb
  169. sudo apt-get install -f -y
  170. rm virtualbox-3.1_3.1.6-59338_Ubuntu_karmic_${arch}.deb
  171. else
  172. cd /home/$USER/
  173. wget http://download.virtualbox.org/virtualbox/3.1.6/virtualbox-3.1_3.1.6-59338_Ubuntu_karmic_${arch}.deb
  174. dpkg -i --force-all virtualbox-3.1_3.1.6-59338_Ubuntu_karmic_${arch}.deb
  175. sudo apt-get install -f -y
  176. rm virtualbox-3.1_3.1.6-59338_Ubuntu_karmic_${arch}.deb
  177. fi
  178. fi
  179. if [ $i = "Hoz" ]
  180. then
  181. sudo apt-get -y install hoz-gui
  182. fi
  183. if [ $i = "Dvd::rip" ]
  184. then
  185. sudo aptitude -y install transcode && sudo aptitude -y install dvdrip
  186. fi
  187. if [ $i = "Avidemux" ]
  188. then
  189. sudo aptitude -y install avidemux
  190. fi
  191. if [ $i = "Yakuake.Para KDE" ]
  192. then
  193. sudo aptitude -y install yakuake
  194. fi
  195. if [ $i = "Alltray" ]
  196. then
  197. sudo aptitude -y install alltray
  198. fi
  199. done
  200. fi
  201.  

Causas: Esta parte va bien pero cuando eligo varias opciones no se instala ningun programa

Código:
Has elegido la opcion Wine|Gimp

Siguiente

Código
  1. upd=`zenity --title="Actualizar" --text="Has seleccionado Actualizar, Limpiar\n. Hay dos tipos de actualizaciones una normal y otro mas sostificado.\n Si acabas de instalar mejor haz una sostificada. \n Al contrario si lo tenias instalado haz una normal.\n O si deseas limpiar los paquetes innecesarios de tu sistema."  \
  2.    --width="500" --height="450" \
  3.      --list --column="Select" --column="Opciones" \
  4.            --checklist FALSE "Actualizacion normal" FALSE "Actualizacion sostificada" FALSE "Limpiar Ubuntu"`
  5. if [ $? -eq 0 ]
  6. then
  7. for updopc in $upd
  8. do
  9. if [ $updopc = "Actualizacion normal" ]
  10. then
  11. zenity --info --title="INFO" --text="Este proceso lo mas seguro que no tarde mucho.\n Espere a que salga la ventana de informacion"
  12. sudo aptitude update && sudo apt-get update
  13. sleep 2
  14. zenity --info --title="INFO" --text="Ya se ha actualizado su sistema"
  15. clear
  16. break
  17. elif [ $updopc = "Actualizacion sostificada" ]
  18. then
  19. echo ""
  20. zenity --info --title="INFO" --text="Este proceso puede que tarde mucho, espere a que te salga la ventana\n de informacion"
  21. sudo aptitude update && sudo apt-get update
  22. sudo aptitude upgrade && sudo apt-get upgrade
  23. zenity --info --title="INFO" --text="Ya se ha actualiza tu sistema"
  24. sleep 2
  25. clear
  26. fi
  27. if [ $updopc = "Limpiar Ubuntu" ]
  28. then
  29. echo "chekpoint"
  30. zenity --info --title="Limpieza.." --text="Ahora empezara la limpieza de Ubuntu"
  31.     sudo apt-get autoremove && sudo apt-get autoclean && sudo apt-get clean
  32.     OLDCONF=$(dpkg -l|grep "^rc"|awk '{print $2}')
  33.     CURKERNEL=$(uname -r|sed 's/-*[a-z]//g'|sed 's/-386//g')
  34.     LINUXPKG="linux-(image|headers|ubuntu-modules|restricted-modules)"
  35.     METALINUXPKG="linux-(image|headers|restricted-modules)-(generic|i386|server|common|rt|xen)"
  36.     OLDKERNELS=$(dpkg -l|awk '{print $2}'|grep -E $LINUXPKG |grep -vE $METALINUXPKG|grep -v $CURKERNEL)
  37.     YELLOW="\033[1;33m"
  38.     RED="\033[0;31m"
  39.     ENDCOLOR="\033[0m"
  40.     zenity --info --title="Limpiando" --text="$YELLOW""Cleaning apt cache...""$ENDCOLOR"
  41.     sudo aptitude clean
  42.     zenity --info --title="Limpiando" --text="$YELLOW""Removing old config files...""$ENDCOLOR"
  43.     sudo aptitude purge $OLDCONF
  44.     zenity --info --title="Limpiando" --text="$YELLOW""Removing old kernels...""$ENDCOLOR"
  45.     sudo aptitude purge $OLDKERNELS
  46.     zenity --info --title="Limpiando" --text="$YELLOW""Emptying every trashes...""$ENDCOLOR"
  47.     rm -rf /home/*/.local/share/Trash/*/** &> /dev/null
  48.     rm -rf /root/.local/share/Trash/*/** &> /dev/null
  49.     clear
  50.     mop=`zenity --title="P.A.U" --text="¿Tenia usted instalado mozilla-thunderbird?" \
  51. --list --column="Select" --column="Opcion" \
  52. --checklist FALSE "SI" FALSE "NO"`
  53.  
  54. fi
  55. done
  56. fi
  57.  

Su error que cuando se selecciona una opcion no se ejecuta y no se me ocurre que hacer

y este es el ultimo

Código
  1. var=otro
  2. if [ $var = "otro" ]
  3. then
  4. ot=`zenity --title="P.A.U" --text="Has entrado en el menu de otros.\n Aqui van diferentes opciones" \
  5. --width="500" --height="450" \
  6. --list --column="Select" --column="Opciones" \
  7. --checklist FALSE "Iconos del menu sistema" FALSE "Quitar sonido de inicio" FALSE "Poner el sonido de inico"  FALSE "Instalar Sharpfonts" FALSE "Arreglar el 'apt-get update' con los repositorios de Google"  FALSE "Resetear el 'apt-get update'" FALSE "Borrar Ubuntu-docs" FALSE "Instalar Ubuntu-docs" FALSE "Botones a la Izquierda" FALSE "Botones a la Derecha" FALSE "Instalar paquetes basicos de compilacion" FALSE "Instalar las librerias de desarrollo del kernel"`
  8. if [ $? -eq 0 ]
  9. then
  10. for otopc in $ot
  11. do
  12. if [ "$otopc" = "Iconos del menu sistema" ]
  13. then
  14. gconftool-2 --type Boolean --set /desktop/gnome/interface/menus_have_icons True && killall gnome-panel
  15. fi
  16. if [ "$otopc" = "Quitar sonido de inicio" ]
  17. then
  18. sudo -u gdm gconftool-2 --set /desktop/gnome/sound/event_sounds --type bool false
  19.                 sudo -u $ON_USER "DBUS_SESSION_BUS_ADDRESS="$DBUS_SESSION_BUS_ADDRESS gconftool-2 --set /desktop/gnome/sound/event_sounds --type bool false
  20. fi
  21. if [ "$otopc" = "Poner el sonido de inicio" ]
  22. then
  23. sudo -u gdm gconftool-2 --set /desktop/gnome/sound/event_sounds --type bool true
  24.                 sudo -u $ON_USER "DBUS_SESSION_BUS_ADDRESS="$DBUS_SESSION_BUS_ADDRESS gconftool-2 --set /desktop/gnome/sound/event_sounds --type bool true
  25. fi
  26. if [ "$otopc" = "Instalar Sharpfonts" ]
  27. then
  28. zenity --info --text="Esto tardara dependiendo de tu conexion"
  29. cd /tmp/
  30. zenity --info --text="Ahora se instalara cabextract"
  31. sudo apt-get -y install cabextract
  32. zenity --info --text="Ya se ha instalado.\n Ahora se descargar lo necesirio"
  33. wget http://sharpfonts.com/fonts/andale32.exe
  34.                 wget http://sharpfonts.com/fonts/arial32.exe
  35.                 wget http://sharpfonts.com/fonts/arialb32.exe
  36.                 wget http://sharpfonts.com/fonts/comic32.ex
  37.                 wget http://sharpfonts.com/fonts/courie32.exe
  38.                 wget http://sharpfonts.com/fonts/georgi32.exe
  39.                 wget http://sharpfonts.com/fonts/impact32.exe
  40.                 wget http://sharpfonts.com/fonts/tahoma32.exe
  41.                 wget http://sharpfonts.com/fonts/times32.exe
  42.                 wget http://sharpfonts.com/fonts/trebuc32.exe
  43.                 wget http://sharpfonts.com/fonts/verdan32.exe
  44.                 wget http://sharpfonts.com/fonts/webdin32.exe
  45. sudo mkdir /usr/share/fonts/truetype/
  46. cabextract -d /usr/share/fonts/truetype/ andale32.exe arial32.exe arialb32.exe comic32.exe courie32.exe georgi32.exe impact32.exe tahoma32.exe times32.exe trebuc32.exe verdan32.exe webdin32.exe
  47. wget http://sharpfonts.com/fontconfig.tbz
  48.                 tar xvjpf fontconfig.tbz -C /etc/fonts/
  49.                 rm -r /tmp/*.exe
  50.                 rm /tmp/fontconfig.tbz
  51. fi
  52. if [ "$otopc" = "Arreglar el 'apt-get update' con los repositorios de Google" ]
  53. then
  54. echo "Acquire::http::Pipeline-Depth \"0\";" | sudo tee -a /etc/apt/apt.conf.d/90localsettings > /dev/null
  55. fi
  56. if [ "$otopc" = "Resetear el 'apt-get update'"]
  57. then
  58. sudo rm /etc/apt/apt.conf.d/90localsettings_back; sudo cp /etc/apt/apt.conf.d/90localsettings /etc/apt/apt.conf.d/90localsettings_back; cat /etc/apt/apt.conf.d/90localsettings_back | sudo sed -e '/^Acquire::http::Pipeline-Depth.*/d' > /etc/apt/apt.conf.d/90localsettings; sudo rm /etc/apt/apt.conf.d/90localsettings_back
  59. fi
  60. if [ "$otopc" = "Borrar Ubuntu-docs" ]
  61. then
  62. zenity --info --text="Esto te liberara 256MB"
  63. sudo apt-get -y remove ubuntu-docs
  64. fi
  65. if [ "$otopc" = "Instalar Ubuntu-docs" ]
  66. then
  67. sudo apt-get -y install ubuntu-docs
  68. fi
  69. if [ "$otopc" = "Botones a la Izquierda" ]
  70. then
  71. gconftool-2 --type string --set /apps/metacity/general/button_layout "menu:close,minimize,maximize"
  72. fi
  73. if [ "$otopc" = "Botones a la Derecha" ]
  74. then
  75. zenity --info --title="INFO" --text="Ahora se cambiara los botones"
  76. gconftool-2 --type string --set /apps/metacity/general/button_layout "close,minimize,maximize:menu"
  77. fi
  78. if [ "$otopc" = "Instalar paquetes basicos de compilacion" ]
  79. then
  80. sudo aptitude -y install build-essential
  81. fi
  82. if [ "$otopc" = "Instalar las librerias de desarrollo del kernel" ]
  83. then
  84. sudo aptitude -y install linux-headers-`uname -r`
  85. fi
  86. done
  87. fi
  88.        fi
  89.  

Este no se ejecuta ninguna de las opciones que hay y este es el error que me da cuando ejecuto alguna opcion

Código:
[: 90: missing ]
[: 90: missing ]

Lo siento por el post tan largo o era poner esto para ir diciendo parte por parte o poner todo el script de mas de 400 lineas, lo he estado dando vueltas pero no he conseguido como hacerlo funcionar si alguien me puede ayudar
Código
  1.  


« Última modificación: 30 Abril 2010, 19:58 pm por Afsoon » En línea

leogtz
. . .. ... ..... ........ ............. .....................
Colaborador
***
Desconectado Desconectado

Mensajes: 3.069


/^$/


Ver Perfil WWW
Re: Dudas con con partes de mi script [Bash]
« Respuesta #1 en: 30 Abril 2010, 23:00 pm »

Citar
furulan
Código:
Aviso
La palabra furular no está en el Diccionario.

Por otra parte, no creo poder ayudarte (y los demás tampoco), porque el código es ineficiente, usas demasiados IF's, ni si quiera usas "elifs"; ya se te había hecho la recomendación que adaptarás tu código a "case", y no lo has hecho.


En línea

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

Desconectado Desconectado

Mensajes: 130


Ver Perfil
Re: Dudas con con partes de mi script [Bash]
« Respuesta #2 en: 1 Mayo 2010, 08:43 am »

Todos los script de instalacion de programas que hay usan IF's, de todos los que he mirado ninguno tiene case ya que no te deja elegir varias opciones a la vez y eso en los programas es ineficiente para eso lo haces escribiendolo y si te parece ineficiente el codigo no se lo va a parecer a todo el mundo lo mismo, yo he publicado esto para saber donde tengo el error no para que me digan que el codigo es ineficiente y que uso demasiados IF's es que todos los script de instalacion usan IF's ninguno usaba "case"
En línea

Afsoon

Desconectado Desconectado

Mensajes: 130


Ver Perfil
Re: Dudas con con partes de mi script [Bash]
« Respuesta #3 en: 1 Mayo 2010, 09:48 am »

ya lo he resuelto y gracias por la NO ayuda
En línea

leogtz
. . .. ... ..... ........ ............. .....................
Colaborador
***
Desconectado Desconectado

Mensajes: 3.069


/^$/


Ver Perfil WWW
Re: Dudas con con partes de mi script [Bash]
« Respuesta #4 en: 1 Mayo 2010, 22:01 pm »

De nada, y anda y sigue cometiendo los mismos errores, así llegarás muy lejos.
En línea

Código
  1. (( 1 / 0 )) &> /dev/null || {
  2. echo -e "stderrrrrrrrrrrrrrrrrrr";
  3. }
  4.  
http://leonardogtzr.wordpress.com/
leogutierrezramirez@gmail.com
Páginas: [1] Ir Arriba Respuesta Imprimir 

Ir a:  

Mensajes similares
Asunto Iniciado por Respuestas Vistas Último mensaje
Error en script y dudas sobre grep.
Scripting
Vehlore 0 1,705 Último mensaje 9 Junio 2015, 20:45 pm
por Vehlore
Dudas con for en bash
Scripting
gregory90 1 1,586 Último mensaje 28 Abril 2016, 16:23 pm
por gregory90
dudas script
Scripting
inma55 7 10,349 Último mensaje 21 Febrero 2024, 15:19 pm
por elektrostudios2
dudas script (volumen 3)
Scripting
inma55 1 1,007 Último mensaje 20 Noviembre 2023, 11:52 am
por reymosquito
WAP2 - Aviso Legal - Powered by SMF 1.1.21 | SMF © 2006-2008, Simple Machines