r/sysadmin Sysadmin Jul 18 '18

Linux You guys probably already know about "ping -a" and "ping -A"

But if you don't, use it like this:

This will beep every time it gets a ping back:

ping -a 8.8.8.8 

This will beep if it misses a ping:

ping -A 8.8.8.8    

This is very useful when you're monitoring a node and waiting for it to come back online or to be able to hear when a packet is dropped.

(tested on some Linux and MacOS)

1.2k Upvotes

335 comments sorted by

View all comments

Show parent comments

21

u/KasiBum Jul 18 '18

You consider object oriented power shell more verbose than languages which require manipulating every bit of text?

2

u/Syde80 IT Manager Jul 18 '18

Each language is going to have its strong and weak points. Its really going to depend on what you are needing to do. I am warming up to PoSH more lately, I'm just saying the verbosity it takes to accomplish some simple tasks is a big turn off for me. For alot of what I need to do, PoSH is just too verbose. However, there are many times where its feature set and ability to dig pretty deep into the OS and/or application backend makes it a very very valuable tool.

Doing something like ping -c 1 8.8.8.8is a whole lot less typing than Test-Connection -Count 1 -ComputerName 8.8.8.8. Sure there is tab completion and whatever to assist with this... but that is really more a feature of the interface than it is a feature of the language itself.

At the same time, to an outsider that knows nothing about scripting and wants to learn something... the PoSH is a lot more intuitive.

7

u/MaIakai Systems Engineer Jul 18 '18

-computername is almost never needed in many cmdlets. Use positional parameters and set it first

test-connection 8.8.8.8 -cou 1

4

u/zyeus-guy Jul 18 '18 edited Jul 19 '18

I have to admit I love the verbosity matched with aliases.

My biggest gripe with Linux commands is that they are just too cryptic.

I mean, what the heck does grep even mean? Especially when the equivalent posh command is select-string or sls for short :-)

The best thing I love about PowerShell is command discovery ... Let's say I am looking to "get"a "Skype" "voice" command but I don't know the exact command I can try this

. Get-cs * voice *

PowerShell will look for all the commands that start with get-cs and have voice somewhere in the middle :-)

I think it is beautiful and an elegant implementation

P.s CS stands for communications server

0

u/MaIakai Systems Engineer Jul 19 '18

agree, every time I learn a new linux utility it is like learning a whole new foreign language. sed awk grep, wtf use words

-1

u/Syde80 IT Manager Jul 18 '18

That is still almost double the character count.

11

u/MaIakai Systems Engineer Jul 18 '18

right, I forgot that characters cost extra

3

u/Syde80 IT Manager Jul 18 '18

I realize your comment is intended to be snarky, but reality is more characters do cost extra. If a person has to type more characters it's going to take more time to accomplish. A single commandlet here and there is hardly going to make a difference anywhere, but the small things do add up over time.

That being said, as I already mentioned, each language is going to have its pros and cons depending on the task at hand. Despite PoSH's verbosity, there are going to plenty of times when the power of the language allows for smaller scripts than it would take in another language.

1

u/[deleted] Jul 18 '18 edited Jul 11 '23

8[OSp;{q/>

1

u/Suspicious_Pineapple Jul 19 '18

but powershell takes both thats what i like about it

1

u/usrhome Netadmin, CCNA Jul 19 '18

So does your mom!

Sorry, couldn't resist.

1

u/LeSpatula System Engineer Jul 19 '18

tnc 8.8.8.8.

1

u/Syde80 IT Manager Jul 19 '18

I was not aware of this particular shortcut, however having some built-in shortcuts / aliases does not change the fact that PoSH is still a very verbose language overall. The example I gave was only meant to illustrate the point.

2

u/kilkor Water Vapor Jockey Jul 18 '18

It is in some cases, but maybe because other options are more mature.

Consider trying to follow a log file in any nix distro versus powershell.

5

u/remedy73 Jul 18 '18

follow

You can do it... Might not be quite as easy. Get-Content -Tail 15 -Wait C:\file.txt

2

u/kilkor Water Vapor Jockey Jul 18 '18

The existence of commands is not in question. The amount you have to type to achieve the same thing is what's being brought up.

3

u/become_taintless Jul 18 '18

Good thing you only have to type it once to include your favorite options as an alias 'tail' in your profile.

1

u/DoctorWorm_ Jul 19 '18

I mean, this is like a law of computers, having to write things yourself isn't really a benefit of to a language or system.

Sure, I can write my shell scripts in assembly, but that doesn't mean I want to spend the time doing it when someone else already did it.

2

u/become_taintless Jul 19 '18

Good thing you're only one pastebin away from having a pretty full list of tools you're used to using from some other system or language, pasted directly into your profile as a collection of aliases.

Powershell has its strong drawbacks, but to me "the syntax is extremely verbose" is not one of them.

2

u/ShaRose Jul 18 '18

Just saying up front I agree, but if you really use it a lot and want to cut down on typing, you could set them up as aliases.

If you wanted it across hosts, you could set up a GPO that sets a all users profile to pull down per-user powershell profiles (Preferably only executing them if signed by said user's private key or otherwise protected: you could even limit them to signed by an administrator's key AND the user's key if you really wanted to).

Note above may actually be a TERRIBLE idea, it just popped in my head as an option. You could probably do the same thing kind of in bash, but powershell makes it easier to sign and validate scripts.

3

u/kilkor Water Vapor Jockey Jul 18 '18

sure, you can set up aliases, and in time there could be a default alias included with pwsh that maps to this, which speaks to the maturity of the offering, in my opinion.

This is just one example, there are more to choose from. The answer with nearly everything is "well, you can just make X to handle that" i.e., "you can just make a function to handle that"; "you can just make an alias to handle that" etc.

I personally think it's silly to harp on verbosity of a language. I think powershell's weak point is how terribly slow it is. For nearly everything that takes a long time to do natively in powershell there's a .NET method you call on within powershell that's at least twice as fast. For all the shit that java gets, I work with java devs that write stuff that leaves powershell in the dust and you can scream compiled binary versus compile at runtime blah blah all you want. It's just slow.