bash-5.0-6 trying to run the following script results in syntax-error:
wget -nv -O index.html "https://de.wikibooks.org/w/index.php?title=Spezial%3APrefixindex&namespace=0&from=$buch"
the resulting error-message:
2020-08-24 20:38:51 URL:https://de.wikibooks.org/w/index.php?title=Spezial:Pr%C3%A4fixindex&namespace=0&from=Mathematik%3A_Lineare_Algebra [96400] -> "index.html" [1]
get_wikibooks.sh: 18: Syntax error: Unterminated quoted string
it seems, that the sign "%" causes the error. But how can I write the script, so that it is useable ?
thanks in advance bye hans
P.S. My complete code is:
set -x
#!/bin/bash
buch=$(zenity --entry --title "Download eines Wikibooks" --text "Bitte geben Sie den Buchtitel an:")
buch=$(echo $buch | sed "s/ /_/g")
mkdir -p ~/wikibooks/$buch
cd ~/wikibooks/$buch
wget -nv -O index.html 'https://de.wikibooks.org/w/index.php?title=Spezial%3APrefixindex&namespace=0&from=$buch'
if [ $? -ne 0 ] ; then
zenity --error --title "Download eines Wikibooks - Fehler" \
--text "Ein Fehler ist aufgetreten\! \nÜberprüfen sie die Internet-Verbindung und den Buchtitel."
fi
wget -nv -c $(cat index.html | tr '"' '\n’ | egrep "^/wiki$buch" | sort -u | sed "s#^#https://de.wikibooks.org#")
if [ $? -ne 0 ] ; then
zenity --error --title "Download eines Wikibooks - Fehler" \
--text "Ein Fehler ist aufgetreten\! \nÜberprüfen sie die Internet-Verbindung und den Buchtitel."
fi
for i in $(ls); do sed "s#href=\"/wiki/$buch#href=\"./$buch#g" $i > $i.temp; mv $i.temp $i; done
zenity --info --title "Download eines Wikibooks" --text "Herunterladen des Buches erfolgreich\!"
wget -nv -O index.html "https://de.wikibooks.org/w/index.php?title=Spezial%3APrefixindex&namespace=0&from=$buch"
on my machine with GNU bash, version4.4.20(1)-release
and it worked fine. The unterminated quotation must be elsewhere in yourget_wikibooks.sh
file.get_wikibooks.sh
?index.html
file without an error message. My$buch
variable is obviously empty. Could the value of that variable be where the problem is in your case?$buch
in your line, there should not be such an error. Try addingset -x
to get a debug output of what is executed. And please add the script you execute around line 18%
sign. You need to show us line 18 which, it would seem, is after thewget
command.