Skip to content

Instantly share code, notes, and snippets.

@Termiux
Created October 31, 2011 17:30
Show Gist options
  • Save Termiux/1328084 to your computer and use it in GitHub Desktop.
Save Termiux/1328084 to your computer and use it in GitHub Desktop.
mailCheck
#!/bin/bash
#
# This scripts check if user has a proper .forward file
# if not present script will ask for mail and finger info
# on login given is on proper login folder
#
#Get user data
username=`whoami`
fullName=`finger $username | grep 'Name' | cut -d ':' -f3`
userHome=`finger $username | grep 'Directory' | cut -d ' ' -f2`
mailFile=`ls $userHome -Al | grep '.forward' | awk '{ print $9 }'`
mail=''
#
# Check if users mailFile is set, if not ask for mail and other data too
#
if [ ! -e $userHome/.forward ]
then
echo "Your info is not in the system please provide it"
chfn
echo "E-mail address (so we can forward all mail to you)"
read mail
echo $mail > .forward
echo "All done!"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment