Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- cat ./sfp.sh
- #!/bin/sh
- # Router URL
- LOGIN_URL="http://192.168.1.254/boaform/admin/formLogin?username=admin&password={PASSWORD}&save=Login&submit-url=%2Fadmin%2Flogin.asp"
- STATUS_URL="http://192.168.1.254/status_pon.asp"
- # Fetch the content of the status page using the authenticated session
- curl -s "$LOGIN_URL" > /dev/null
- # Fetch the content of the status page using the authenticated session
- html_content=$(curl -s "$STATUS_URL")
- # Define an array of the parameters you want to extract
- #parameters=("Temperature" "Voltage" "Tx Power" "Rx Power" "Bias Current")
- echo
- for param in "Temperature" "Tx Power" "Rx Power" "Voltage" "Bias Current"; do
- # Use grep to find the line with the parameter and then use sed to extract the value
- value=$(echo "$html_content" | grep -A1 "$param" | tail -n1 | sed -n 's/.*>\(.*\)<\/.*/\1/p')
- # Extract the numerical part of the value (including negative sign)
- numerical_value=$(echo $value | awk '{print $1}')
- # Extract the unit of the value
- unit=$(echo $value | awk '{print $2}')
- # Round off the value to 2 decimal points
- rounded_value=$(printf "%.2f" $numerical_value)
- echo $param: $rounded_value $unit
Advertisement
Add Comment
Please, Sign In to add comment