3.17.28.48 |    

Navigation

Google Advertisement

Diese Funktion Überprüft mit lynx ob eine Seite erreichbar ist. Als Rückgabewert wird "true" oder "false" zurückgegeben.

checkConnection
  1. #!/bin/bash
  2.  
  3. # ********************************************************************
  4. # Diese Funktion ueberprueft ob eine Seite erreichbar ist. Als
  5. # Rueckgabewert wird "true" oder "false" zuruegegeben.
  6.  
  7. function checkConnection() {
  8.  
  9. local url=$1
  10. local connect=$( lynx --head --dump $url 2>/dev/null | grep 'HTTP' | sed 's/^\(HTTP.*\) \([0-9]\{1,\}\)\(.*\)/\2/g' )
  11.  
  12. # if HTTP status "moved" or "ok" - web page is reachable...
  13. if [ "$connect" = "200" -o "$connect" = "302" ]; then
  14. 	true
  15. else
  16. 	false
  17. fi
  18.  
  19. }
  20.  
  21. # Beispiel fuer Aufruf...
  22. if ! checkConnection "http://www.google.de" ; then
  23. 	echo "Leider ist die Seite nicht erreichbar!"
  24. fi
Parsed in 0.002 seconds at 355.49 KB/s

Search
 
Full text search by name and content of a snippet.

User online
There are 2 users online.

Tags Cloud

Latest snippets
str2seconds
(Bash::Function)
is_integer
(Bash::Function)
file_rotate
(Bash::Function)
confirm
(Bash::Function)
is_workingtime
(Bash::Function)
last day of last month
(Bash::Snippets)
crypt_apr1_md5
(PHP::Function)
crypt_apr1_md5
(Perl::Function)
transparent
(CSS)
rfc2822Toiso8601
(PHP::Function)