PDA

Archiv verlassen und diese Seite im Standarddesign anzeigen : Problem mit Shell Script



Klaus1
21.08.07, 15:37
Hallo!

Bräuchte mal eure Hilfe zu folgendem Shell Script.
Ich bekomm einen Vergleich zweier GIF Dateien mit dem md5sum Befehl in einer IF BEDINGUNG nicht hin. Hätt schon AWK verwendet.

LOGIK sollte wie folgt funktionieren:
FALLS BILD1 != BILD2 AKTION ausführen, sonst ELSE Zweig.

Hier das Script, welches auf OPENWRT läuft:


if [ "`md5sum /tmp/voip-status/old_current.gif | awk`{print $1}``" == \
"`md5sum /tmp/voip-status/very_current.gif || awk`{print $1}``"]; then
echo "Status has not changed."
else
cp /tmp/voip-status/very_current.gif /tmp/voip-status/old_current.gif
echo "Current VoIP status has changed"
if ["`md5sum /tmp/voip-status/very_current.gif | awk`{print $1}``" == \
"`md5sum online-Voip.gif | awk`{print $1}``"]; then
echo "New status: We are online"
fi
if ["`md5sum /tmp/voip-status/very_current.gif | awk`{print $1}``" == "`md5sum offline-Voip.gif | awk`{print $1}``"]; then
echo "New status: We are offline"
fi
fi

zyrusthc
21.08.07, 16:08
Versuche es mal so:

if [ $(md5sum /tmp/voip-status/old_current.gif | cut -d" " -f1) == \
$(md5sum /tmp/voip-status/very_current.gif | cut -d" " -f1) ]; then
echo "Status has not changed."
else
.......
fi

Greeez Oli

Klaus1
21.08.07, 16:49
die erste bedingung klappt, aber die weitere hier nicht:



if [ $(md5sum /tmp/voip-status/very_current.gif | cut -d" " -f1) == \
$(md5sum /bin/voip/online-Voip.gif | cut -d" " -f1) ]; then
echo "New status: We are online"
fi

if [ $(md5sum /tmp/voip-status/very_current.gif | cut -d" " -f1) == \
$(md5sum /bin/voip/offline-Voip.gif | cut -d" " -f1) ]; then
echo "New status: We are offline"
fi

Fehleroutput:
root@OpenWrt:/bin/voip# ./test.sh
[: missing ]
./test.sh: ./test.sh: 4: 1d1040f800fc71292ba751e038353864: not found
[: missing ]
./test.sh: ./test.sh: 9: e3dcbba1baaaac1a8dd273420874b619: not found

Tritt nur bei nicht identischer MD5SUM auf!

zyrusthc
21.08.07, 17:21
Mach statt 2 if Abfragen hintereinander nur eine und die zweite bauste in die erste mit elif ein!