[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Is perl still the No.1 language for sysadmin?



David Christensen wrote:

> # echo $PATH | tr ':' '\n' | perl -MFile::Slurp -ne
>    'chomp;@e=read_dir($_,prefix=>1); print map "$_\n",@e'|xargs
>    file|perl -pe 's/\S+\s+//'|grep -v 'symbolic link'|perl -pe
>    's/, dynamically linked.+//'|sort|uniq -c|sort -rn

I'm still so impressed by this, I tried to run this but it
seems I lack the Slurp module?

Also, if it isn't too much to ask, can you put it in the form
of a script or shell function the way you would? It doesn't
feel right for me to "indent your code" if you follow ...

>> Side note, many guys say they only use sh because bash, zsh
>> etc requires them being installed, I don't see how that can
>> be problem on Unix systems. Of course, zsh can't be moved
>> to a computer without zsh itself, but how is that less
>> portable just because they add super-cryptic syntax to do
>> fancy stuff?
>
> AIUI the practice has been to write Bourne shell scripts
> because nearly every Unix or Unix-like system has
> /bin/sh installed.
>
> Unfortunately, userland tools on different Unix and
> Unix-like operating systems or platforms do not have the
> same names (paths), do accept the same options, do not
> produce the same output, and/or do not produce the same
> warnings and/or errors. This includes /bin/sh.
>
> One of my favorite Perl sysadmin tricks is to generate shell
> commands and run them on remote hosts via SSH. In the past,
> I have installed /bin/bash everywhere to simplify the Perl
> code. My current practice is to keep the shell commands
> simple enough so as to avoid the incompatibilities.

Ah, it is like a biggest denominator which requires no further
installs and can be used everywhere (and in the future) with
no change to it. Good example with ssh, I understand now.

-- 
underground experts united
https://dataswamp.org/~incal


Reply to: