Tiny Core Base > TCB Tips & Tricks
How to find which extension provides a file
GNUser:
Maybe Robert used ifconfig+grep to look for Bcast just as a fast screening test: If this screening test fails, there's definitely no working network connection so it's pointless to continue. If this test succeeds, there is a chance that there's a working network connection--the program can then attempt to perform a network task (if failure is acceptable) or proceed to a test that's more specific but more time-consuming (e.g., ping or nslookup).
Rich:
Hi GNUser
This timed out in 1 second with no connectivity:
--- Code: ---ping -W 1 -c 1 8.8.8.8 2>&1 > /dev/null
--- End code ---
It returns instantly with connectivity.
This timed out in 12 seconds with no connectivity:
--- Code: ---ping -W 1 -c 1 google.com 2>&1 > /dev/null
--- End code ---
This timed out in 24 seconds with no connectivity:
--- Code: ---nslookup "repo.tinycorelinux.net" 2>&1 > /dev/null
--- End code ---
GNUser:
--- Quote from: Rich on November 19, 2024, 10:22:17 PM ---Hi GNUser
This timed out in 1 second with no connectivity:
--- Code: ---ping -W 1 -c 1 8.8.8.8 2>&1 > /dev/null
--- End code ---
It returns instantly with connectivity.
--- End quote ---
Hi Rich. Thanks for the tests. Sounds like this one is both fast and reliable, so it gets my vote despite the two cosmetic issues (hardwired address, big company) I mentioned previously.
CNK:
--- Quote from: Rich on November 18, 2024, 05:41:24 PM ---Hi CNK
--- Quote from: CNK on November 18, 2024, 04:36:19 PM --- ... I'd also suggest showing the help info if provides.sh is run with no arguments.
--- End quote ---
I initially did that, but then reverted back to exit 1 because I didn't want to
risk changing a behavior that a program or script might be relying on.
--- End quote ---
Maybe only output the help info when called with no arguments if "[ -t 1 ]" is true, indicating that the output is to a terminal, not a pipe (more info here)?
The 1s ping might be so short it gives false negatives sometimes, since the first ping response can be exceptionally delayed if networking hardware is in a sleep state or eg. WiFi signal is poor. The automatic retrieval in provides.sh has always annoyed me really. I prefer how "apt-file" on Debian has a separate update command that you run manually. But I guess I can always make my own version too.
Rich:
Hi CNK
--- Quote from: CNK on November 19, 2024, 11:33:55 PM --- ... The 1s ping might be so short it gives false negatives sometimes, ... ... But I guess I can always make my own version too.
--- End quote ---
This is not cast in stone. That's why I requested comments.
If I change it to this:
--- Code: ---ping -A -W 1 -c 2 8.8.8.8 2>&1 > /dev/null
--- End code ---
It timed out in 2 seconds with no connectivity and still
returned instantly with connectivity.
The -A flag made the instant response possible:
--- Code: ----A Ping as soon as reply is recevied
--- End code ---
I think that still sounds quite reasonable.
Navigation
[0] Message Index
[#] Next page
[*] Previous page
Go to full version