Hola gente de T!
Bueno el cuento es así, estaba aburrido y un amigo me dijo por que no te armas algo para ver la tabla de posiciones y esto es lo que me salio.
primero las imágenes para que vean como me quedo:
Cuando lo ejecutamos nos mostrara esta:
Y luego esta otra:
Script con yad
Simplemente hermoso no?
Bueno pasemos al código.
El script de las imagenes usa Yad para la parte gráfica, así que hay que tenerlo instalado para que funcione correctamente.
el código:
#!/bin/bash
#===============================================================================
#
# FILE: Tabla.sh
#
# USAGE: ./Tabla.sh
#
# DESCRIPTION: ---
#
# OPTIONS: ---
# REQUIREMENTS: Yad
# BUGS: ---
# NOTES: ---
# AUTHOR: ..::Due204::..
# ORGANIZATION: ---
# CREATED: ---
# REVISION: ---
#===============================================================================
yad --progress --pulsate --percentage=50 --auto-close --auto-kill --center --title="Descargando..." --text="Por favor espere." &
TABLA=`curl -l http://www.ole.com.ar/estadisticas.html`
POSICION=`echo "$TABLA" | grep '<td class="ancho-20"' | cut -d '>' -f2 | cut -d '<' -f1`
EQUIPO=`echo "$TABLA" | grep '<td class="ancho-160"><a href=' | cut -d '>' -f3 | cut -d '<' -f1`
PUNTOS=`echo "$TABLA" | sed 671,4590d | grep '<td class="ancho-60"><p' | cut -d '>' -f3 | cut -d '<' -f1`
PARTIDOS=`echo "$TABLA" | sed 671,4590d | grep '<td class="ancho-60">' | sed /pts/d`
NUMEROS=`echo "$TABLA" | sed 671,4590d | grep '<td class="ancho-60">' |
sed /pts/d | cut -d '>' -f2 | cut -d '<' -f1 > /tmp/fichero`
PARJU=`for a in 1 7 13 19 25 31 37 43 49 55 61 67 73 79 85 91 97 103 109 115; do head -n $a /tmp/fichero | tail -n 1; done`
PARGA=`for a in 2 8 14 20 26 32 38 44 50 56 62 68 74 80 86 92 98 104 110 116; do head -n $a /tmp/fichero | tail -n 1; done`
PAREM=`for a in 3 9 15 21 27 33 39 45 51 57 63 69 75 81 87 93 99 105 111 117; do head -n $a /tmp/fichero | tail -n 1; done`
PARPE=`for a in 4 10 16 22 28 34 40 46 52 58 64 70 76 82 88 94 100 106 112 118; do head -n $a /tmp/fichero | tail -n 1; done`
GOLFA=`for a in 5 11 17 23 29 35 41 47 53 59 65 71 77 83 89 95 101 107 113 119; do head -n $a /tmp/fichero | tail -n 1; done`
GOLCO=`for a in 6 12 18 24 30 36 42 48 54 60 66 72 78 84 90 96 102 108 114 120; do head -n $a /tmp/fichero | tail -n 1; done`
items=( )
for i in `seq 1 20`
do
POSIC=`echo "$POSICION" | head -$i | tail -1`
EQUIP=`echo "$EQUIPO" | head -$i | tail -1`
PARJO=`echo "$PARJU" | head -$i | tail -1`
PARGO=`echo "$PARGA" | head -$i | tail -1`
PAREO=`echo "$PAREM" | head -$i | tail -1`
PARPO=`echo "$PARPE" | head -$i | tail -1`
GOLFO=`echo "$GOLFA" | head -$i | tail -1`
GOLCA=`echo "$GOLCO" | head -$i | tail -1`
PUNTO=`echo "$PUNTOS" | head -$i | tail -1`
items+=( "$POSIC" "$EQUIP" "$PARJO" "$PARGO" "$PAREO" "$PARPO" "$GOLFO" "$GOLCA" "$PUNTO" )
done
killall yad
yad --no-buttons --list --image="/home/user/ruta_a_la_imagen.png"
--width="1200" --height="520" --title="Tabla de Posiciones"
--column="Posicion" --column="Equipo"
--column="Partidos Jugados" --column="Partidos Ganados"
--column="Partidos Empatados" --column="Partidos Perdidos"
--column="Goles a Favor" --column="Goles en Contra"
--column="Puntos" "${items[@]}"
# Final del camino...
Y aca esta la imagen de costado:
Nota: Lo único que hay que modificar al script es la ruta a la imagen, cambien donde dice /home/user/ruta_a_la_imagen.png por la ruta de la imagen.
Para los que no quieren renegar instalando yad les dejo el mismo script pero con zenity, este viene en la mayoría de las distros o si no la tienes en tu sistema de seguro que se encuentran en tus repos.
#!/bin/bash
#===============================================================================
#
# FILE: Tabla.sh
#
# USAGE: ./Tabla.sh
#
# DESCRIPTION: ---
#
# OPTIONS: ---
# REQUIREMENTS: Zenity
# BUGS: ---
# NOTES: ---
# AUTHOR: ..::Due204::..
# ORGANIZATION: ---
# CREATED: ---
# REVISION: ---
#===============================================================================
zenity --progress --pulsate --percentage=50 --auto-close --auto-kill --title="Descargando..." --text="Por favor espere." &
TABLA=`curl -l http://www.ole.com.ar/estadisticas.html`
POSICION=`echo "$TABLA" | grep '<td class="ancho-20"' | cut -d '>' -f2 | cut -d '<' -f1`
EQUIPO=`echo "$TABLA" | grep '<td class="ancho-160"><a href=' | cut -d '>' -f3 | cut -d '<' -f1`
PUNTOS=`echo "$TABLA" | sed 671,4590d | grep '<td class="ancho-60"><p' | cut -d '>' -f3 | cut -d '<' -f1`
PARTIDOS=`echo "$TABLA" | sed 671,4590d | grep '<td class="ancho-60">' | sed /pts/d`
NUMEROS=`echo "$TABLA" | sed 671,4590d | grep '<td class="ancho-60">' |
sed /pts/d | cut -d '>' -f2 | cut -d '<' -f1 > /tmp/fichero`
PARJU=`for a in 1 7 13 19 25 31 37 43 49 55 61 67 73 79 85 91 97 103 109 115; do head -n $a /tmp/fichero | tail -n 1; done`
PARGA=`for a in 2 8 14 20 26 32 38 44 50 56 62 68 74 80 86 92 98 104 110 116; do head -n $a /tmp/fichero | tail -n 1; done`
PAREM=`for a in 3 9 15 21 27 33 39 45 51 57 63 69 75 81 87 93 99 105 111 117; do head -n $a /tmp/fichero | tail -n 1; done`
PARPE=`for a in 4 10 16 22 28 34 40 46 52 58 64 70 76 82 88 94 100 106 112 118; do head -n $a /tmp/fichero | tail -n 1; done`
GOLFA=`for a in 5 11 17 23 29 35 41 47 53 59 65 71 77 83 89 95 101 107 113 119; do head -n $a /tmp/fichero | tail -n 1; done`
GOLCO=`for a in 6 12 18 24 30 36 42 48 54 60 66 72 78 84 90 96 102 108 114 120; do head -n $a /tmp/fichero | tail -n 1; done`
items=( )
for i in `seq 1 20`
do
POSIC=`echo "$POSICION" | head -$i | tail -1`
EQUIP=`echo "$EQUIPO" | head -$i | tail -1`
PARJO=`echo "$PARJU" | head -$i | tail -1`
PARGO=`echo "$PARGA" | head -$i | tail -1`
PAREO=`echo "$PAREM" | head -$i | tail -1`
PARPO=`echo "$PARPE" | head -$i | tail -1`
GOLFO=`echo "$GOLFA" | head -$i | tail -1`
GOLCA=`echo "$GOLCO" | head -$i | tail -1`
PUNTO=`echo "$PUNTOS" | head -$i | tail -1`
items+=( "$POSIC" "$EQUIP" "$PARJO" "$PARGO" "$PAREO" "$PARPO" "$GOLFO" "$GOLCA" "$PUNTO" )
done
killall zenity
zenity --list --width="1100" --height="580"
--title="Tabla de Posiciones" --column="Posicion" --column="Equipo"
--column="Partidos Jugados" --column="Partidos Ganados"
--column="Partidos Empatados" --column="Partidos Perdidos"
--column="Goles a Favor" --column="Goles en Contra"
--column="Puntos" "${items[@]}"
# Fin xD
Como verán es el mismo script pero con zenity en vez de yad.
Si alguien tiene problema con los script pídanme y les paso el link por media así no tienen problemas.
Bueno gente espero que les guste, pueden modificar el código a su antojo y necesidades.
Hasta la próxima.