Advertisement
grandfathermagic

get ip and port from file and check if valid

May 25th, 2022
815
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.46 KB | None | 0 0
  1. #!/bin/bash
  2. source /root/INFO
  3. rx='([1-9]?[0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])'
  4.  
  5. for ip in $ip_to_check; do
  6.  
  7.    if [[ $ip =~ ^$rx\.$rx\.$rx\.$rx$ ]]; then
  8.       echo "valid:     "$ip
  9.    else
  10.       echo "not valid: "$ip
  11.    fi
  12. done
  13.  
  14. if [ "$server_port" -ge 1 ] && [ "$server_port" -le 65535 ]; then echo "$server_port is valid port number";
  15. elif [ "$server_port" -ge 65536 ] && [ "$server_port" -le 1 ]; then echo "$server_port is  not a valid port number"; fi
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement