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

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



On 4/2/23 14:38, Emanuel Berg wrote:
David Christensen wrote:

For sysadmin, I *use* what comes on the platform.  On Debian:

2023-04-02 13:40:08 root@taz ~
# cat /etc/debian_version ; uname -a
11.6
Linux taz 5.10.0-21-amd64 #1 SMP Debian 5.10.162-1
(2023-01-21) x86_64 GNU/Linux

2023-04-02 13:40:17 root@taz ~
# 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
    1868 ELF 64-bit LSB pie executable, x86-64, version 1 (SYSV)
     356 POSIX shell script, ASCII text executable
     192 Perl script text executable
      40 Python script, ASCII text executable
      36 Bourne-Again shell script, ASCII text executable
      30 setuid ELF 64-bit LSB pie executable, x86-64, version 1 (SYSV)
      20 ELF 64-bit LSB executable, x86-64, version 1 (SYSV)
      16 setgid ELF 64-bit LSB pie executable, x86-64, version 1 (SYSV)
      14 Tcl script, ASCII text executable
      10 ELF 64-bit LSB pie executable, x86-64, version 1 (GNU/Linux)
       8 POSIX shell script, UTF-8 Unicode text executable
       4 Python script, UTF-8 Unicode text executable
       4 POSIX shell script, ASCII text executable, with very long lines
       2 a /usr/bin/env sh script, ASCII text executable
       2 a /bin/mksh script, UTF-8 Unicode text executable
       2 Python script, ISO-8859 text executable
       2 Java source, UTF-8 Unicode text
       2 ELF 64-bit LSB executable, x86-64, version 1 (GNU/Linux)
       2 Bourne-Again shell script, ASCII text executable [...]

Psychedelic! :O

Well done!

Okay, so there is more Perl than Python, but both are
prominent, so maybe and should have an understanding of both
then ... and not so difficult to do, right?

But you change that stuff, or use Perl/Python as glue? If you
are, maybe either works pretty well, ey?


The idea of userland tools that read lines of plaintext from standard input, write lines of plaintext to standard output, and whose input and output streams can be strung together into pipelines was novel at the time:

https://en.wikipedia.org/wiki/Pipeline_(Unix)


On 4/2/23 14:59, Emanuel Berg wrote:
> 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.


> I mean, it isn't the features we port, but the shell?


In this context, I would interpret "port" to mean compiling the shell program from source code on a specific operating system or platform. So, to run a Zsh script on a given computer, the Zsh program needs to be compiled and installed on that computer. Package managers allow an expert to do the former and everyone else to do the latter.


David


Reply to: