Ich wurde gefragt, wie das nochmal mit dem überspringen der Abfrage beim hldsupdatetool unter Linux funktioniert.
Es gibt dafür viele Ansätze. Einer ist z.B. das Umleiten von "Yes" direkt an das Programm hldsupdatetool.
|
Source code
|
1
|
echo "Yes" | ./hldsupdatetool.bin
|
Ein weiterer Ansatz wäre Here-Document:
|
Source code
|
1
2
3
|
./hldsupdatetool.bin <<HIER_IST_DAS_ENDE
Yes
HIER_IST_DAS_ENDE
|
Im Regelfall verwendet man EOF für END-Markierung:
|
Source code
|
1
2
3
|
./hldsupdatetool.bin <<EOF
Yes
EOF
|
Letztendlich ist Here-String genau die Lösung, nach der ich lange Zeit gesucht habe:
|
Source code
|
1
|
./hldsupdatetool.bin <<<"Yes"
|
Als kleines Häppchen noch ein Codingbeispiel, wie man es machen könnte:
|
Source code
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
|
#!/bin/bash
STEAMTOOLURL="http://storefront.steampowered.com/download/hldsupdatetool.bin"
STEAMTOOLFILE="hldsupdatetool.bin"
STEAMINSTALLDIR="/home/server/serverfiles"
#colors
RED="tput setf 4"
GREEN="tput setf 2"
NORM="tput op"
checkWritePath() {
touch "$1/temp$$" 2> /dev/null || return 1
rm "$1/temp$$"
return 0
}
getSteamInstaller() {
cd "$2"
wget -q -nc "$1" || return 1
return 0
}
installSteamTool() {
which uncompress > /dev/null || return 1
cd "$2"
chmod u+x "$1"
echo "Installiere steam"
"./$1" >/dev/null <<<"Yes"
[ -x ./steam ] || return 2
echo -e "Aktualisiere steam \c"
for (( n=2 ; n <= 4; n++ )); do
echo -e "..\c"
./steam &> /dev/null && break
done
if ./steam &> /dev/null; then
echo
return 0
else
echo
return 3
fi
}
checkWritePath "$STEAMINSTALLDIR" ||
{ $RED; echo "Keine Schreibrechte auf "$STEAMINSTALLDIR""; $NORM; exit ;}
echo "Lade $STEAMTOOLFILE herunter"
getSteamInstaller "$STEAMTOOLURL" "$STEAMINSTALLDIR" ||
{ $RED; echo "Download fehlgeschlagen"; $NORM; exit ;}
installSteamTool "$STEAMTOOLFILE" "$STEAMINSTALLDIR"
case $? in
0) $GREEN; echo "Update des Steamtools erfolgreich"; $NORM ;;
1) $RED; echo "Uncompress fehlt"; $NORM; exit ;;
2) $RED; echo "Entpacken von steam fehlgeschlagen"; $NORM; exit ;;
3) $RED; echo "Update fehlgeschlagen"; $NORM; exit ;;
esac
|