Logo 
Search:

Unix / Linux / Ubuntu Article

Submit Article
Comments on Find the lines containing a number in a file

Find the lines containing a number in a file.


Sanjeet Kumar
Sanjeet Kumar from IndiaJun 13
Hi All,
I am writing a script which give notification through mail when passwrod will be exprie.E.g. i want notification of password expiry befor 15 days of password expiry.Could you please suggest about the script.

I have writren script in LINUX flavour by using "chage" command,but this command is not working in SOLARIS.
My code is as below:

#!/bin/sh
datediff()
{
d1=$(date -d "$1" +%s)

d2=$(date -d "$2" +%s)

return $(( ($d1 - $d2) / 86400 ))
}
d1=$(chage -l user_name | grep "Password expires" | cut -d ":" -f 2 | cut -d "," -f 1)
d2=$(date '+%h %d')


d3=$(chage -l user_name | grep "Last password change")
d4=$(chage -l user_name | grep "Password expires")
#d5=$(chage -l user_name | grep "Password inactive")
d6=$(chage -l applsupp | grep "Maximum number of days between password change")
datediff "$d1" "$d2"
pwd_exp=$?
#-----------------------------If Else Loop for email alert---------------------------------------------------------#

if [ $pwd_exp -le 15 ]
then
echo -e "Your Password Will Expire In $pwd_exp Days.
else
date
echo "Password expiry has not yet crossed threshold "
fi
Sanjeet Kumar
Sanjeet Kumar from IndiaJun 12
I want password exipry script on solaris flavour not on LINUX.Please provide that


Please enter your Comment
  • Comment should be atleast 15 Characters.
  • Please put code inside [Code] your code [/Code].