diff options
| author | Horus3 | 2014-09-09 19:56:08 +0200 |
|---|---|---|
| committer | Horus3 | 2014-09-09 19:56:08 +0200 |
| commit | b45a707a4a18ab5308d00b288023ae46988ab7a6 (patch) | |
| tree | 626af68b1aa8b6012aff9bbee300f411cd20bdd3 /get.sh | |
| download | pokewiki-b45a707a4a18ab5308d00b288023ae46988ab7a6.tar.gz | |
init commit
Diffstat (limited to 'get.sh')
| -rwxr-xr-x | get.sh | 50 |
1 files changed, 50 insertions, 0 deletions
@@ -0,0 +1,50 @@ +#!/bin/bash + +# text datei mit pokemons +FILE="test.txt" + +# url zum (poke-)wiki +WIKI="http://pokewiki.de/" + +# speicherpfad für heruntergeladenen webseiten +SAVEPATH="./" + +### CONF ENDE ### + + +# teste ob textdatei angegeben wurde +if [ ! -f $FILE ]; then + echo "'$FILE' not a file." 1>&2 + exit 1 +fi + +# teste ob wiki url angegeben wurde +if [ -z "$WIKI" ]; then + echo "No URL given." 1>&2 + exit 1 +fi + +# bestimme anzahl der schleifen iterationen +LINES=$(wc -l "$FILE" | cut -d ' ' -f 1) + +if [ $LINES == 0 ]; then + echo "$FILE has 0 lines." 1>&2 + exit 1 +fi + +for ((i=1;i<=$LINES;i++)); do + # lese pokemon aus der textdatei aus + POKEMON=$(cat "$FILE" | cut -d ' ' -f 2 | sed -n ${i}p) + + # teste, ob datei früher schon einmal heruntergeladen wurde + if [ -f $POKEMON.txt ]; then + read -p "$(tput setaf 1)Warnung! $(tput bold)$POKEMON.txt$(tput sgr0) $(tput setaf 1)existiert schon. Sollen die Informationen überschrieben werden?$(tput sgr0) [Y/n] " answer + if [ "x$answer" == "xn" ]; then + continue + fi + fi + + echo "Lade Informationen zu $(tput setaf 3)'$POKEMON'$(tput sgr0) runter." + # speichere datei in textdatei + elinks -dump "${WIKI}${POKEMON}" > ${SAVEPATH}${POKEMON}.txt +done |
