gpz1100

Untitled

Sep 27th, 2025
41
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.18 KB | None | 0 0
  1. cat ./sfp.sh
  2. #!/bin/sh
  3.  
  4.  
  5. # Router URL
  6. LOGIN_URL="http://192.168.1.254/boaform/admin/formLogin?username=admin&password={PASSWORD}&save=Login&submit-url=%2Fadmin%2Flogin.asp"
  7. STATUS_URL="http://192.168.1.254/status_pon.asp"
  8.  
  9. # Fetch the content of the status page using the authenticated session
  10. curl -s "$LOGIN_URL" > /dev/null
  11.  
  12. # Fetch the content of the status page using the authenticated session
  13. html_content=$(curl -s "$STATUS_URL")
  14.  
  15. # Define an array of the parameters you want to extract
  16. #parameters=("Temperature" "Voltage" "Tx Power" "Rx Power" "Bias Current")
  17.  
  18. echo
  19.  
  20. for param in "Temperature" "Tx Power" "Rx Power" "Voltage" "Bias Current"; do
  21. # Use grep to find the line with the parameter and then use sed to extract the value
  22. value=$(echo "$html_content" | grep -A1 "$param" | tail -n1 | sed -n 's/.*>\(.*\)<\/.*/\1/p')
  23.  
  24. # Extract the numerical part of the value (including negative sign)
  25. numerical_value=$(echo $value | awk '{print $1}')
  26.  
  27. # Extract the unit of the value
  28. unit=$(echo $value | awk '{print $2}')
  29.  
  30. # Round off the value to 2 decimal points
  31. rounded_value=$(printf "%.2f" $numerical_value)
  32.  
  33. echo $param: $rounded_value $unit
  34.  
  35.  
  36.  
Advertisement
Add Comment
Please, Sign In to add comment