Advertisement
Guest User

Untitled

a guest
Feb 17th, 2017
367
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.59 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. Check(){
  4. wget -4q --tries=10 --timeout=20 --spider http://google.com
  5. [[ $? -eq 0 ]] && echo 1 || echo 0
  6. }
  7.  
  8. Weather(){
  9.     wget -4qO- https://p.ya.ru/$1 |\
  10.     html2text -utf8 | head -4 |\
  11.     sed '2d;s/Сегодня //g;s/[[:alpha:]]/\u&/;s/.˚C/ ˚C/' > ~/.weather/temp
  12.     local str1=$(cat ~/.weather/temp | sed -n 1p)
  13.     local str2=$(cat ~/.weather/temp | sed -n 2p)
  14.     local str3=$(cat ~/.weather/temp | sed -n 3p)
  15.    
  16.     echo "$str1 $str2"
  17.     echo "$str3"
  18. }
  19.  
  20. sleep 3
  21. if [ "$(Check)" == 1 ]; then
  22.     Weather 20
  23.     Weather dubna
  24. else
  25.     echo "No internet"
  26. fi%
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement