Advertisement
Guest User

Bash Reconnect Script Telekom Speedport W723V Typ B for NAS

a guest
Jan 26th, 2013
387
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #!/bin/sh
  2. ########################################################
  3. # Reconnect Script Telekom Speedport W723V Typ B
  4. # schapplm, 26.01.2013
  5. # Vorlage: Philipp Immel 2012 April 13 für W723V Typ A
  6. ########################################################   
  7. # Description: Reconnects Speedport W 723V router Typ B
  8. # Syntax: recon
  9. # Extern: read printf echo curl grep awk sleep rm
  10. ########################################################
  11.  
  12. #----------------------
  13. # Read router password
  14. #----------------------
  15. password="YOURPASSWORD"
  16.  
  17. #---------------------------
  18. # Check external IP address
  19. #---------------------------
  20. echo "Fetching external IP address …"
  21. OLDIP=$( curl -s http://checkip.dyndns.org | sed 's/[a-zA-Z/<> :]//g' )
  22. echo "Your IP before reconnect:" $OLDIP
  23.  
  24. #----------------------------------------------
  25. # Log on to router and get a session ID cookie
  26. #----------------------------------------------
  27. echo "Logging in …"
  28. curl --user-agent "Mozilla/4.0" --location --cookie-jar "/volume1/pyload/SessionID.txt" --data "pws=$password" --data "login_pwd=2" --referer "https://speedport.ip/hcti_start_passwort.stm" --insecure  "https://speedport.ip/cgi-bin/login.cgi" &> /dev/null
  29. sleep 1
  30.  
  31. #----------------------------------------------
  32. # Execute Disconnect and Connect Script
  33. #----------------------------------------------
  34. echo "Reconnect …"
  35. curl --user-agent "Mozilla/4.0" --location --cookie-jar "/volume1/pyload/SessionID.txt" --insecure "https://speedport.ip/cgi-bin/disconnect.exe" &> /dev/null
  36. sleep 3
  37. curl --user-agent "Mozilla/4.0" --location --cookie-jar "/volume1/pyload/SessionID.txt" --insecure "https://speedport.ip/cgi-bin/connect.exe" &> /dev/null
  38.  
  39. #-------------------------
  40. # Log out from the router
  41. #-------------------------
  42. echo "Logging off …"
  43. curl --location --insecure --cookie "/volume1/pyload/SessionID.txt" "https://speedport.ip/cgi-bin/logout.cgi" &> /dev/null
  44. sleep 10
  45.  
  46. #---------------------------
  47. # Check external IP address
  48. #---------------------------
  49. echo "Fetching external IP address …"
  50. NEWIP=$( curl -s --data "dummy=42" --connect-timeout 120 "http://checkip.dyndns.org/dummy/" | sed 's/[a-zA-Z/<> :]//g' )
  51.  
  52. #-------------------
  53. # Check for success
  54. #-------------------
  55. if [ "$OLDIP" != "$NEWIP" ] && [ "$NEWIP" != "" ]
  56. then
  57.     echo "Reconnect has been successful. Your new IP address is:" $NEWIP
  58. else
  59.     echo "Reconnect has not been successful. Please try again. Your IP address is still:" $OLDIP
  60. fi
  61.  
  62. #--------------------
  63. # Remove cookie file
  64. #--------------------
  65. rm /volume1/pyload/SessionID.txt
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement