uabrc / devops-docs

https://docs.rc.uab.edu/devops-docs/
Apache License 2.0
1 stars 5 forks source link

Identifying researchers who do not have RC accounts (on Cheaha) #30

Open wwarriner opened 1 year ago

wwarriner commented 1 year ago

From Mike

users='wwarr mhanby, cmclung, ravi89'  # misspelling on purpose
users="`echo ${users} | tr '[:upper:]' '[:lower:]' | tr '\n' ' ' | tr ',' ' ' | tr -s ' '`"

for user in $(echo $users); do
  if ! getent passwd $user 1>/dev/null ; then
    echo $user does not exist;
  fi
done
wwarriner commented 1 year ago

Put this in .bashrc to use.

function cheaha-users-exist() {
  users="`echo ${@} | tr '[:upper:]' '[:lower:]' | tr '\n' ' ' | tr ',' ' ' | tr -s ' '`"

  for user in $(echo $users); do
    if ! getent passwd $user 1>/dev/null ; then
      echo $user does not exist;
    fi
  done
}