So basically what this command does is securely connect to a web domain to grab my external IP address, this works flawlessly on a Linux Debian system, but it is not working right on my OpenBSD system. Curl command works fine, however something is up with the Grep command as it just isn't grabbing the IP that curl is piping to it..
Does -Eo not work with OpenBSD? I cannot tell with the man page..
USERAGENT="Mozilla/4.0"
WEB_LOCATION="https://duckduckgo.com/?q=whats+my+ip"
curl -s --retry 3 --max-time 5 -tlsv1.2 --user-agent $USERAGENT $WEB_LOCATION | grep -Eo '\<[[:digit:]]{1,3}(\.[[:digit:]]{1,3}){3}\>'
******* RESOLVED (Kinda) ********
I worked out that for some reason this particular pattern :
grep -Eo '\<[[:digit:]]{1,3}(\.[[:digit:]]{1,3}){3}\>'
was not working on OpenBSD, but this long version does..
grep -Eo '[[:digit:]]{1,3}\.[[:digit:]]{1,3}\.[[:digit:]]{1,3}\.[[:digit:]]{1,3}'
Why this is the case is very confusing, as the first search pattern works fine on all the versions of Debian Linux I have used!
The issue is with the word boundary patterns in your regexp, which are [[:<:]]
and [[:>:]]
in OpenBSD but \<
and \>
respectively in Debian (and possibly other Linux distributions).
grep -Eo '[[:<:]][[:digit:]]{1,3}(\.[[:digit:]]{1,3}){3}[[:>:]]'
should work.
Read the man page for details.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With