Results 1 to 6 of 6
  1. #1
    Join Date
    Apr 2013
    Posts
    3

    Unanswered: how to set up newgrp on .profile

    Hello all,

    I am having an issue setting up an environment on .profile. I want to set up my .profile in that way that everytime I login to the host, it should automatically set up my group. I tried the folllowing but it doesn't work. It is on the solaris OS.

    HOSTNAME=$(hostname)

    if [[ "$HOSTNAME" = "tpat1a" ]] || [[ "$HOSTNAME" = "tpat2a" ]]
    then
    newgrp unixteam
    umask 002
    fi

    Any help will be appreciated.

    Thanks
    PT

  2. #2
    Join Date
    Sep 2009
    Location
    Ontario
    Posts
    1,057
    Provided Answers: 1
    You have to already be a member of 'unixteam'. Are you?

  3. #3
    Join Date
    Apr 2013
    Posts
    3
    yes, the group is there. I can set it from the command line but it won't execute from .profile.

  4. #4
    Join Date
    Sep 2009
    Location
    Ontario
    Posts
    1,057
    Provided Answers: 1
    Is the newgrp statement ahead of your path statement

  5. #5
    Join Date
    Apr 2013
    Posts
    3
    No, it is provided after the Path at the very last. I have a file with a path name and newgrp and other required environment. Group can be set after I execute the file. But it is just not working when I placed it in .profile.

  6. #6
    Join Date
    Sep 2009
    Location
    Ontario
    Posts
    1,057
    Provided Answers: 1
    Add some echo statements to see how the code is running.

    Code:
    HOSTNAME=$(hostname)
    echo hostname is $HOSTNAME 
    if [[ "$HOSTNAME" = "tpat1a" ]] || [[ "$HOSTNAME" = "tpat2a" ]]
    then
      echo My if statement works 
       newgrp unixteam
       umask 002
    fi

Posting Permissions

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