AIX

 View Only
  • 1.  ksh93

    Posted Sat November 20, 2021 10:01 AM

    Hello all!

    I've been scripting with ksh93 for a quite some time (especially after reading the excellent "Learning the Korn Shell - 2nd Edition", by Bill Rosenblatt & Arnold Robbins, published by O'Reilly) and decided to also try it as my interactive shell.

    Out of the box it has some interesting features, like command retrieve with the arrow keys, history search and command/file name completion --much like Linux, perhaps a little better.

    Has anyone tried/adopted/rejected?


    Kind regards,

    F. Alejandro Osso



  • 2.  RE: ksh93

    Posted Sat November 20, 2021 11:31 AM
    On Sat, Nov 20, 2021 at 03:01:24PM +0000, F. Alejandro Osso via IBM Community wrote:
    > Out of the box it has some interesting features, like command retrieve with the arrow keys, history search and command/file name completion --much like Linux, perhaps a little better.

    I recommend to customers that they use ksh93 instead of installing
    bash for interactive users. It means the pandora's box of RPM packages
    is left closed.

    > Has anyone tried/adopted/rejected?

    There's a problem. IBM has said that only KSH is supported as the root
    shell. You can not change root or padmin away from KSH or you will
    have an unsupported system.

    https://www.ibm.com/support/pages/can-i-change-root-or-another-system-account-users-default-shell

    Having spoken to support on this matter before, opening a feature
    request (RFP?) to change AIX's root shell from KSH to KSH93 would be
    the best way to change this.

    ------------------------------------------------------------------
    Russell Adams Russell.Adams@AdamsSystems.nl
    Principal Consultant Adams Systems Consultancy
    http://adamssystems.nl/




  • 3.  RE: ksh93

    IBM Champion
    Posted Mon November 22, 2021 04:00 AM
    Hi Alejandro,

    I use ksh93 as an interactive shell on daily basis since years. There are a lot of useful features in ksh93 and it is really very good for scripting.

    But as Russel said - don't change root's default shell. You can still use ksh93 as root's interactive shell (I do usually sudo -i /bin/ksh93).

    Best regards
    Andrey Klyachkin

    ------------------------------
    Andrey Klyachkin

    https://www.power-devops.com
    ------------------------------



  • 4.  RE: ksh93

    Posted Mon February 19, 2024 09:53 AM

    Hello,

    I've also been scripting in ksh93 from 2003 until 2021.

    As a system administrator I wrote some object oriented scripts thanks to this guy Using Types To Create Object Orientated Korn Shell 93 Scripts « Musings (fpmurphy.com).

    It had all the features I needed (string manipulation, arithmetic operations, etc.).

    Unlike bash (as far ad I know) it is possible to open several files together for writing and reading thanks to file descriptors.

    The main drawback was that my colleagues were not willing to make the effort of understanding it.

    As now, I still see some people writing things like i=`expr $i + 1` instead of (( i++ )) or echo $str1 " " $str2 > file  instead of print -u3 -f "%s %s\n" "$str1" "$str2"

    Or uglier things like var=`echo $var | awk -F. { print $1 }' | awk -F- { print $2 }'` in a 10000-iteration loop.

    It upsets me.

    When David Korn was hired by Google (can't remember when), the future of ksh became uncertain. As of 01/01/2024 the latest release is ksh 93u+m/1.0.8.

    Sorry for my English.

    Cheers,

    Jean-Philippe Henry

    AIX/Linux system administrator.



    ------------------------------
    Jean-Philippe Henry
    ------------------------------



  • 5.  RE: ksh93

    Posted Mon February 19, 2024 10:26 AM
    All very true 

    Am I missing a question in your post? Or you're just venting?





  • 6.  RE: ksh93

    Posted Sun February 25, 2024 10:05 AM

    I'm just agreeing with F. Alejandro Osso, and, perhaps, a little venting. You're right 😁



    ------------------------------
    Jean-Philippe Henry
    ------------------------------



  • 7.  RE: ksh93

    Posted 30 days ago

    I ran across a guy early in my IBM career who used Korn shell for literally everything. I seem to recall he created a database of sorts with Korn! And there are no doubt many ksh coders more clever than myself. I've "borrowed" many a ksh technique over my career. I remember once struggling to make a sophisticated korn shell script work in a particular, "efficient" way (or so I imagined--as I recall, I was trying to make extensive use of "non-standard" file descriptors). In my table pounding Charlie Brown frustration of trying to get the script to work the way I imagined it should, a colleague behind me calmly interjected:

    "I had a college professor who drilled into our heads a mantra: First, make it work. Then, make it fast. Then make it small. Why don't you first try to get it to work in the simplest way you can imagine--never mind how clumsy and inefficient it may seem?"

    I listened to my (now nameless) colleague, and I had a working prototype by EOD! Over the years since, I've fixed bugs, added features, and used the heck out of that little utility. It still runs like a charm--more useful than a Swiss army knife! And IIRC, I never did go back and try to make it more sophisticated, but I did find a few (simpler) ways to make it faster. In fact, to my great surprise, my shell script outperformed an IBM provided compiled binary program with similar functionality. Kinda of a KISS tale, I guess.



    ------------------------------
    Mackey Morgan
    ------------------------------



  • 8.  RE: ksh93

    Posted 30 days ago

    khs93 has also excellent builtin documentation capability via getopts, so <script> --man gives you full documentation and --help gives you the options only. 

    There is a community maintained version of ksh93, on my Gentoo print ${.sh.version} gives me Version AJMv 93u+m/1.1.0-alpha+3f177bfd 2021-09-13. Unfortunately IBM treats ksh93 so poorly. For example on AIX 7.3 the socket IO doesn't work any more 

    ~$ < /dev/tcp/localhost/22
    -ksh93: /dev/tcp/localhost/22: cannot open [A file or directory in the path name does not exist.]
    

    There is no discussion group here about scripting with ksh, I suppose IBM doesn't consider Korn shell as programming language. It is not so fancy-schmancy after all. Just a work horse for decades.

    Best regards



    ------------------------------
    Plamen Tanovski
    ------------------------------