New on LowEndTalk? Please Register and read our Community Rules.
All new Registrations are manually reviewed and approved, so a short delay after registration may occur before your account becomes active.
All new Registrations are manually reviewed and approved, so a short delay after registration may occur before your account becomes active.
Bash script to ping by subnet
Microlinux
Member
in Tutorials
I had need for simple up/down status in an easily mechanized format . . . and I haven't used xargs in a while, so I wrote this little gem (the beauty is in the eye of the beholder).
I thought someone else might find it useful.
Thanked by 1obakfahad
Comments
Just use:
That's not as easily mechanized, fun or the same. I had a very specific need, but yeah, there are many ways to skin the cat.
There is also a "grepable" format suitable for use in other scripts (with 'grep' as the name says).
Why not use fping?
fping -g 127.0.0.0/8
That guy wrote a script and shares it for free. That should be good enough, no?
Yes, sure there are other ways. So what? Should we stop once we have anything doing a given job? No! The whole open source world we all profit from is based on (among other factors) having options and variety and people trying new ways to do things.
Professionally speaking I like his script for three simple reasons: It's liteweight, a sh(ell) is always and everywhere available, and everyone can easily look at it and understand it (which is far less true for, say, nmap).
@bsdguy - It's fight club and these are some of the big boys, so no worries, they can take it. Besides, I've learned more stuff from these guys (and others) battling it out over the last couple of years then anywhere else. So I prefer they have at it.
Primarily, because I can't.
I would write an exhaustive list of reasons I did not use each and every existing potential solution, but I simply don't have time.
A very interesting way to generate a list of IPs given CIDR notation
Do you think it is a good idea to create bash scripts for such simple functionalities which are easily invoked through software that is most likely installed in your system? We are not talking about passing 15 flags to nmap/fping/whatever but one or two. Plus I don't see the problem on giving feedback about this.
I will try not be ambiguous so as to prevent further wasted typing.
1.) The tools at my disposal are existing software packages. Your installed software list doesn't match mine. I promise it doesn't. Swear to god.
2.) I cannot install new software packages.
3.) The reason I cannot install other software packages is policy. This policy is not up for debate, no how badly you would like to argue it. You could give me a million dollars to change it ... I wouldn't be able to. It's not an option. At all.
4.) I need output in this specific format.
5.) Any format other than this specific format, is not acceptable. No matter how badly you want it to be, it's not. Seriously, it's not. I mean it's really not.
6.) I need it to be fast, I have more hardware resources than flexibility at my disposal. I know how badly you want to tell me that's not your situation, or how dumb that is. None of that changes my situation.
7.) Please re-read 1 to 6 at least two more times. Really digest it. Take notes, have an argument with yourself in your head, that's right - get it all out.
Relevant feedback is: "hey, I have a better bash function for xyz" or "hey, I found a bug!".
Relevant feedback is not "WHY DON'T DON'T YOU USE XYZ TOOL, BECAUSE LORD ALMIGHTY IT'S WHAT I WOULD DO".
I posted this script here because I figured maybe someone else could find it useful, or perhaps modify it to be useful to them. I find the hoopla amusing, but I hope this explanation saves key strokes.
@outime
That's not the point. The point is a) variety/options is good, b) sh scripts are a tool of the trade for admin jobs, c) Hey, someone is sharing his script. Take it or it leave it, as you please. But don't hit on it.
Sidenote: I like nmap. A lot. But it's way heavier than a sh script. Besides, it's not everywhere installed.
I personally wouldn't use his script myself. But I can respect his work, his idea, his reasoning and, most of all, his sharing his stuff.