Advertisement
Guest User

Untitled

a guest
Aug 26th, 2019
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.57 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. ping_targets="google.com2"
  4. failed_hosts=""
  5. file="alma2.txt"
  6. for i in $ping_targets
  7. do
  8.    ping -c 1 $i > /dev/null
  9.    if [ $? -ne 0 ]; then
  10.       if [ "$failed_hosts" == "" ]; then
  11.          failed_hosts="$i"
  12.       else
  13.          failed_hosts="$failed_hosts, $i"
  14.       fi
  15.    fi
  16. done
  17.  
  18. if [ "$failed_hosts" != "" ]; then
  19.     echo $failed_hosts
  20.  
  21.   if [ -f "$file" ]
  22.   then
  23.     echo "$file found."
  24.     #ez lényegtelen
  25.   else
  26.     echo "$file not found."
  27.     #email küldés # eza  rész nincs meg
  28.     echo 'qqqq' > $file
  29.   fi
  30.  
  31. else
  32.   rm $file
  33. fi
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement