I made some modifications to the /home/user/.envfile so the PS1 prompt would show date/time as well as the pwd etc.The modification is:# `who am i` is used to obtain the name of the original usercase `who am i | awk '{print $1}'` in    'someuser')        #set the prompt to include the date and time        set -o allexport        unset _Y _M _D _h _m _s        eval $(date +_Y=%Y;_M=%m;_D=%d;_h=%H;_m=%M;_s=%S)        ((SECONDS = 3600*${_h#0}+60*${_m#0}+${_s#0}))        typeset -Z2 _h _m _s        _tsub=(_m=(SECONDS/60%60)) == (_h=(SECONDS/3600%24)) + (_s=(SECONDS%60))        _timehm='${_x[_tsub]}$_h:${_m}'        _timehms='${_x[_tsub]}$_h:$_m:${_s}'        _timedhms=$_Y'/'$_M'/'$_D '${_x[_tsub]}$_h:$_m:${_s}'        _hn=`hostname`        typeset -u _hn        # `whoami` is used here to display the name of the 'su' user        _un=`whoami | awk '{print $1}'`        typeset -u _un        export PS1=$_timedhms'['$_un']'$_hn':${PWD#$HOME/} $ '        set +o allexport    ;;    *)    ;;esacThe prompt should look like:2014/08/07 11:08:24[su'd username]hostname:/home/username $As you can see, this makes use of whoami to display the name of the current user in the prompt.Certain processes we run through this account are complaining:who: 0551-012 The process is not attached to a terminal.        Do not run who am i as a background process.Usage: who [-AabdHilmpqrsTtuwX?] [am {i,I}] [utmp_like_file]Is there any way to prevent that modification from affecting this other process?  Possibly by detecting when the process is not attached to a terminal?
Is there a way to prevent a non-terminal-attached process from executing 'who' inside my .envfile?
ksh;aix;who
stty and older versions of who am i will issue error messages when they're not connected to a tty device. stty checks stdin (fd 0); I don't know what file descriptor who checks. To avoid getting those error messages, the usual workaround has been to use the -t option of test (more commonly known as [) to check if the shell is connected to a tty.if [ -t 0 ]then    ID=`who am i | awk '{print $1}'`else    ID=unknownfiIn your case, you can surround the entire logic that sets up the PS1 variable in that if statement, since PS1 only makes sense when one is working on a tty.The following is the relevant section from the explanation of test in the link above.-t  file_descriptorTrue if file descriptor number file_descriptor is open and is associated with a terminal. False if file_descriptor is not a valid file descriptor number, or if file descriptor number file_descriptor is not open, or if it is open but is not associated with a terminal.