Contact Info

Crumbtrail

ActiveXperts.com » Support » ActiveXperts Network Monitor » Online » Linux » User Existenance

Monitor the existence of a User on a Linux machine using SSH | ActiveXperts Network Monitor

The following script can be used in ActiveXperts Network Monitor to check an SMTP mail server on a remote LINUX machine:

#################################################################################
# ActiveXperts Network Monitor - Shell script checks
#
# For more information about ActiveXperts Network Monitor and SSH, please
# visit the online ActiveXperts Network Monitor Shell Script Guidelines at:
#   https://www.activexperts.com/support/network-monitor/online/linux/
#################################################################################
# Script
#     user-exists.sh
# Description
#     This script will check if a user account exists
# Declare Parameters
#     1) sUsername (string) - Username to check
# Usage
#     user-exists.sh sUsername
# Sample
#     user-exists.sh axuser
#################################################################################

#!/bin/sh

# Validate number of arguments
if [ $# -ne 1 ] ; then
  echo "UNCERTAIN: Invalid number of arguments - Usage: user-exists sUsername"
  exit 1
fi

# Checks if the user exists
if id -u $1 >/dev/null 2>&1; then
  echo "SUCCESS: User exists DATA:1" 
else
  echo "ERROR: User does not exist DATA:0"
fi