[SOLVED] script to provide info necessary for network troubleshooting
Linux - NetworkingThis forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
one would basically need to copy-pasta the source code and save as net-diag.ksh.
then run it as source netdiag.ksh (or change perms like chmod 744 netdiag.ksh then run it like: ./net-diag.ksh).
whatever it spits out should be copy-pastad in the thread (in [code] tags) to give whoever wishes to answer a starting point for determining the issue.
Thanks for the opportunity:
- not testing for binaries to use,
- predictable (fixed) file name instead of using `mktemp`,
- using multiple file names where one would suffice (also see use of 'head'),
- unnecessary use of double ampersands,
- no error checking (does `route | awk '/default/ {print $2}'` always present something one can resolve?).
*Ever heard of 'ss' or 'ip'? Esp. 'ip' can provide a lot of nfo in one tool. And what about protocol focus? UDP and ICMP are one thing but how about TCP? As in 'tcptraceroute'? Or content as in "curl -kI https://something"?
There's no need to do the double ampersands. You can start your script with...
Code:
set -e
See man bash. The set command is detailed at the end.
set -e will stop your script on first error and report the last error exit code. Regarding ip command like unspawn mentions I wrote a blog post which provides an example of obtaining the IP address for the interface of the default route. It uses the ip command.
one would basically need to copy-pasta the source code and save as net-diag.ksh.
then run it as source netdiag.ksh (or change perms like chmod 744 netdiag.ksh then run it like: ./net-diag.ksh).
whatever it spits out should be copy-pastad in the thread (in [code] tags) to give whoever wishes to answer a starting point for determining the issue.
See posts #2 and #4. I would apply that same feedback to your most recent script. Additionally, just because you call a script *.ksh does not make it ksh. The shebang is what really matters unless you execute the script as an argument of the interpreter. In your case, the shebang is #!/bin/bash. So that's a bash script. If you want it to be ksh then you should update the shebang.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.