Wikipedia:Reference desk/Archives/Computing/2017 December 13
Computing desk | ||
---|---|---|
< December 12 | << Nov | December | Jan >> | December 14 > |
Welcome to the Wikipedia Computing Reference Desk Archives |
---|
The page you are currently viewing is an archive page. While you can leave answers for any questions shown below, please ask new questions on one of the current reference desk pages. |
December 13
[edit]Regex for Linux ifconfig
[edit]
ipa=$(ifconfig | grep -Po "inet addr:\K[0-9]?[0-9]?[0-9]?\.[0-9]?[0-9]?[0-9]?\.[0-9]?[0-9]?[0-9]?\.[0-9]?[0-9]?[0-9]?")
This brings both external IP and internal (loopback) IP. Why does the loopback being brought as well? I can use another grep to remove it, but I'd prefer not to, if I have the option. ClinicalCosmologist (talk) 08:06, 13 December 2017 (UTC)
- The question seems to complain that the regexp matches the loopback IP (which I assume to be
127.0.0.1
), but I fail to see why one would expect it not to be matched. By the way, for the IP matching part, it does not matter a whole lot since only "safe" inputs should be given, but the regexp looks awful - I have not tested either but you could shorten it to[0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}
(arguably easier to parse, and avoids matching empty strings for numbers e.g.8.8..1
is a match of the current), or at least correct the first digit of each to[0-2]?[0-9]?[0-9]?\.[0-2]?[0-9]?[0-9]?\.[0-2]?[0-9]?[0-9]?\.[0-2]?[0-9]?[0-9]?
since the IPv4 numbers go from 0 to 255.
- I would assume the real question is why does
ifconfig
return the loopback address. (And the real real question is how to avoid it.) TigraanClick here to contact me 09:20, 13 December 2017 (UTC)
- Thank you for this information, I've learned from that and have implemented the shorter version, it brings the IP just fine. I also added
grep -Po -m1
to make sure to stop in the first match, which is the external IP. I need for a small Bash script, I prefer to avoid giving further details. Again thank you dearly for your help. ClinicalCosmologist (talk) 10:37, 13 December 2017 (UTC)
- Thank you for this information, I've learned from that and have implemented the shorter version, it brings the IP just fine. I also added
- In the shorter version posted by Tigraan above, you should escape the dots, as you did in your original version, since an unescaped dot will match any character. Also, by using -m1, you are relying on ifconfig printing the external IP address first. If it happens to print the loopback address first, this won't work. It would be safer to use something like
grep -Po 'inet addr:\K\d{1,3}\.\d{1,3}\.\d{1,3}.\d{1,3}' | grep -v '127\.0\.0\.1'
And of course if there are multiple external addresses, all of these solutions will fail, but without knowing more about what you are doing I can't comment on how you should handle that. CodeTalker (talk) 16:02, 13 December 2017 (UTC)- Duh! Yes, of course, the dots should be escaped. (How did I even fail to do that when the exemple given did it correctly?) TigraanClick here to contact me 17:15, 13 December 2017 (UTC)
- In the shorter version posted by Tigraan above, you should escape the dots, as you did in your original version, since an unescaped dot will match any character. Also, by using -m1, you are relying on ifconfig printing the external IP address first. If it happens to print the loopback address first, this won't work. It would be safer to use something like
Use Microsoft Word 'manage sources' feature to automate Chicago footnotes
[edit]Hi, I'm writing a paper using Chicago style footnotes. How do I use the 'manage sources' feature to automate these? As far as I can tell, the Chicago option there will only do bracketed citations, not footnotes... Amisom (talk) 17:56, 13 December 2017 (UTC)
Bing and Google Problems?
[edit]After today's Windows 10 update, I can't seem to connect to either Google or Bing. Other websites are fine. All I get is
This site can’t provide a secure connection
www.bing.com uses an unsupported protocol. ERR_SSL_VERSION_OR_CIPHER_MISMATCH HIDE DETAILS Unsupported protocol The client and server don't support a common SSL protocol version or cipher suite.
Rojomoke (talk) 23:40, 13 December 2017 (UTC)
- A reboot and a reinstall of my anti-virus seems to have fixed things. Rojomoke (talk) 19:34, 14 December 2017 (UTC)