Portál AbcLinuxu, 10. května 2025 07:19
if [[ `wget -S --spider URL 2>&1 | grep 'HTTP/1.1 200 OK'` ]]; then echo "true"; fiNevěděl by někdo jak to přepsat i pro /bin/sh?
wget -S --spider URL 2>&1 | grep 'HTTP/1.1 200 OK' if [[ $? -eq 0 ]] then echo "true" fi
var1=`wget -S --spider 'URL' 2>&1 | grep 'HTTP/1.1 200 OK' ` if [ "$var1" ]; then echo "true" fi
if wget -S --spider URL 2>&1 | grep -q 'HTTP/1.1 200 OK'; then echo "true"; fi
Na "grep -q
" pozor, on totiž skončí, jakmile najde vzorek, takže wget
dostane SIGHUP
a skončí také. Takže by bylo potřeba spíš
if wget -S --spider URL 2>&1 | grep 'HTTP/1.1 200 OK' >/dev/null; then echo "true"; fi
if wget -S --spider URL 2>&1; then echo "true"; fi
Tiskni
Sdílej:
ISSN 1214-1267, (c) 1999-2007 Stickfish s.r.o.