AIX Open Source

AIX Open Source

Share your experiences and connect with fellow developers to discover how to build and manage open source software for the AIX operating system

 View Only
  • 1.  bash won't start gives print error and hangs

    Posted Thu November 03, 2022 02:42 PM
    Hi,

    We have an AIX 7.3 NIM server that has the toolkit installed and up to date w/ no errors from `dnf check` and no noteworthy errors from `rpm -Va` ... but as root (this machine only has root), when I try to start bash from root's ksh login shell I get this:

    [root@crilnim1 ~]# bash
    bash: print: command not found
    bash: print: command not found
    bash: print: command not found
    bash: print: command not found
    bash: print: command not found

    ...and it hangs pretty good.  I can't break it with Ctrl-C.  I looked trough ~/.profile and /etc/profile for things that might offend and can't find anything.  Has anyone ever seen this or has a thought on what might be going on?  We have similar AIX 7.3 LPARs that don't exhibit this problem.  The thing is that I just then updated openssh and Python3 from MRS, then ran `updtvpkg` etc.  Then, clean updates with `dnf update` etc.

    So I don't know for sure whether this LPAR was always like this or I just broke it somehow.  In any case, any insights would really be appreciated.  Thanks.

    Mike

    ------------------------------
    Michael Metts
    ------------------------------


  • 2.  RE: bash won't start gives print error and hangs

    Posted Thu November 03, 2022 06:04 PM
    This is bash telling you that it can't find the "print" command, so something in the startup scripts is trying to run that. Is it possible that the PATH is getting munged up before you get to that part of the startup scripts? Or possibly that command is not installed on the problem system(s)?

    I don't think that AIX provides a "print" out of the box, so maybe check the other working systems and see what package owns it. This is assuming that the startup scripts are the same on both systems.

    -- 
    Stephen L. Ulmer
    Enterprise Architect
    Mainline Information Systems






  • 3.  RE: bash won't start gives print error and hangs

    Posted Fri November 04, 2022 03:34 AM

    Are you using bash from AIX toolbox (/opt/freeware/bin/bash) or AIX 7.3 provided bash (/usr/bin/bash) ?

    If you are using /usr/bin/bash can you try using /opt/freeware/bin/bash to see if there is similar problem ?

     

     

    Thanks,

     

    Sanket Rathi

    STSM - AIX Development

    Member IBM Academy of Technology, IBM Master Inventor

    IBM India Systems Development Lab, Hyderabad, India

    Office : +91-40-71857052

     

     






  • 4.  RE: bash won't start gives print error and hangs

    Posted Fri November 04, 2022 04:29 AM
    print is ksh builtin , not a bash builtin. 
    Probably some ksh scripts are copied into .bashrc file.

    ------------------------------
    Ayappan P
    ------------------------------



  • 5.  RE: bash won't start gives print error and hangs

    Posted Fri November 04, 2022 08:56 AM
    You can check the sourced files as follows
    as root:

    # truss -rALL -feado truss.out 

    Look at the kopen files to see what files are source.
    Look for "p r i n t"  

    for example:
    7799008: 23527563: 0.3338: kopen("//.bashrc", O_RDONLY) = 3
    7799008: 23527563: 0.3341: fstatx(3, 0x0FFFFFFFFFFFF7B8, 176, 0) = 0
    7799008: 23527563: 0.3345: kread(3, 0x000000011008FA30, 24) = 24
    7799008: e c h o T E S T\n p r i n t " h e l l o "\n
    7799008: 23527563: 0.3348: close(3) = 0




    ------------------------------
    Jan Harris
    AIX Development Support (Liaison to the AIX Toolbox for Open Source)
    IBM (Contract)
    Austin TX
    ------------------------------



  • 6.  RE: bash won't start gives print error and hangs

    Posted Fri November 04, 2022 10:43 AM
    Hello everyone,

    Thanks for all your responses.  I think we found the problem.  /etc/profile had had these lines added at the bottom:

    if [ $LOGNAME = "root" ]
    then
            export PS1=$LOGNAME@$(hostname -s)':$PWD:# '
    else
            export PS1=$LOGNAME@$(hostname -s)':$PWD:$ '
    fi

    ...which uses print:

    root@crilnim1 ~]# echo $PS1
    $(print -n "[${USER}@${HOST%%.*} ";[[ "$HOME" == "$PWD" ]] && print -n "~" ||([[ "${PWD##*/}" == "" ]] && print -n "/" || print -n "${PWD##*/}");print "]# ")

    And, since bash and ksh both read /etc/environment and then /etc/profile there you are.  In our case, the prompt was also being set in ~/.kshrc so we just commented these lines out and the print error when starting bash went away.

    This does bring up an important point for us which that we have one or two AIX machines which actually have regular shell users (not the machine under discussion above).  They use these machines just like Linux.  I think the vast majority of them don't even know that it's AIX.  They have bash as their default login shell.  On one of those machines, we recently put this at the bottom of /etc/profile to effect the right mixed behavior:

    if [ "${BASH-}" ] && [ "$BASH" != "/bin/sh" ]; then
    if [ -f /opt/freeware/etc/bash.bashrc ]; then
    . /opt/freeware/etc/bash.bashrc
    fi
    fi

    /opt/freeware/etc/bash.bashrc contains a lot of steps but one of the first things it does is move /opt/freeware/bin and /opt/freeware/sbin to the front of PATH because - if it's bash - then the user is non-root and non-admin in our organization so we're trying to give the most Linux/GNU shell we can.  If anyone has ideas on best practices around this topic, I'd love to hear them.

    Best,
    Mike

    ------------------------------
    Michael Metts
    ------------------------------