Professional Web Applications Themes

Customising PS1 environment variable - AIX

I'm currently setting up a couple of nice new RS6000's running AIX 5.2 I'd like to mimic the default behaviour of the PS1 prompt, i.e. keep the $ prompt for normal users and the # prompt for root, but provide more information. default: $ id uid=203(informix) gid=201(informix) groups=1(staff) $ su root's password: # what I'd like: marge /usr/informix/PANACEA $ echo $PS1 marge $PWD $ marge /usr/informix/PANACEA $ su root's password: marge /usr/informix/PANACEA # Note that the $ prompt has changed to the # prompt, to let you know that you're the root user. I've tried numerous methods of doing this, ...

  1. #1

    Default Customising PS1 environment variable

    I'm currently setting up a couple of nice new RS6000's running AIX 5.2

    I'd like to mimic the default behaviour of the PS1 prompt, i.e. keep
    the $ prompt for normal users and the # prompt for root, but provide
    more information.

    default:
    $ id
    uid=203(informix) gid=201(informix) groups=1(staff)
    $ su
    root's password:
    #

    what I'd like:
    marge /usr/informix/PANACEA $ echo $PS1
    marge $PWD $
    marge /usr/informix/PANACEA $ su
    root's password:
    marge /usr/informix/PANACEA #

    Note that the $ prompt has changed to the # prompt, to let you know
    that you're the root user.
    I've tried numerous methods of doing this, but none of them seem to be
    able to produce a customisable $/# prompt, especially for simple su
    (without running of /etc/profile and ~/.profile). I can obviously do
    this within /etc/profile using a simple if statement, but I'd like the
    consistency of
    $ su
    and
    $ su -
    both working.

    Is this possible at all?
    BigCalm Guest

  2. #2

    Default Re: Customising PS1 environment variable

    BigCalm wrote: 
     

    You can have it by using the $ENV script and testing there who you are
    and setting PS1 accordingly: doing a 'su' you still spawn a shell, so
    your $ENV script is executed, if root readable.

    --
    Alberto 'JCN-9000' Varesio AKA BlueRider AIX pSeries System Admin
    Datavision PLM - Cso Svizzera 185 Biker on HONDA CB500 - LHG
    10149 Torino - ITALY +390117710276 Jeeper on Sport TJ - Wave
    A.Varesio()datavisionplm(.)com A.Varesio()dv-plm(.)dnsalias(.)net
    Please http://www.fsf.org/philosophy/no-word-attachments.html, thanks!
    * We have moved: Note the new E-Mail and Address and update, Thanks. *
    --
    Legge della gravitą selettiva
    Un oggetto cadrą sempre in modo da produrre il maggior danno possibile.

    Alberto Guest

  3. #3

    Default Re: Customising PS1 environment variable

    Alberto 'JCN-9000' Varesio <com> wrote in message news:<com>... 

    >
    > You can have it by using the $ENV script and testing there who you are
    > and setting PS1 accordingly: doing a 'su' you still spawn a shell, so
    > your $ENV script is executed, if root readable.[/ref]

    Ok, this has worked exactly the way I want it to - many thanks for
    pointing me in the right direction:

    All I had to do in the end was:
    1) add the following line to /etc/environment:
    ENV=/etc/setprompt.sh

    2) Create a file /etc/setprompt.sh with permissions 755 (owned by
    root):
    TMPUSER=`id -un`
    if [ "$TMPUSER" = "root" ]
    then
    PS1=marge:'$PWD # '
    else
    PS1=marge:'$PWD $ '
    fi

    and, the prompt functions as desired.

    Many thanks for the help

    - Jon

     
    BigCalm Guest

Similar Threads

  1. Replies: 2
    Last Post: June 2nd, 01:58 PM
  2. Reading Environment Variable
    By Les T in forum Coldfusion - Advanced Techniques
    Replies: 0
    Last Post: June 3rd, 11:15 PM
  3. Replies: 0
    Last Post: August 13th, 10:27 AM
  4. #25071 [NEW]: Let include/require look in PHP_INCLUDE environment variable
    By jakob dot nielsen at nhst dot no in forum PHP Development
    Replies: 0
    Last Post: August 13th, 10:23 AM
  5. "Incorrect environment variable PLUS_DFLT"
    By Karsten Farrell in forum Oracle Server
    Replies: 0
    Last Post: December 5th, 06:08 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139