./scriptalertpasswd.sh[7]: echo(7257600 - 691200): not found.
syntax error on line 1 stdin
./scriptalertpasswd.sh[16]: test: 0403-021 A ] character is missing.
syntax error on line 1 stdin
./scriptalertpasswd.sh[16]: test: 0403-021 A ] character is missing.
syntax error on line 1 stdin
./scriptalertpasswd.sh[16]: test: 0403-021 A ] character is missing.
Can you see the extra e that is in bold appended to changeperiod variable? That is causing the pain
Hence the error:
scriptalertpasswd.sh[16]: test: 0403-021 A ] character is missing.
syntax error on line 1 stdin
./scriptalertpasswd.sh[16]: test: 0403-021 A ] character is missing.
Make the code like this:
#!/bin/ksh
# Script for check whose password will expire in 8 days
#
currentdate=`perl -le 'print time'`
changeperiod=$((84*86400))
remindperiod=$((8*86400))
alertperiod=$((changeperiod - remindperiod))
lastchange=`awk '/:/ {name=$1} ; /lastu/ {print name $3}' /etc/security/passwd`
for user in $lastchange
do
username=`echo $user | cut -f 1 -d:`
lastupdate=`echo $user | cut -f 2 -d:`
alertdate=$((alertperiod + lastupdate)) #" | bc`
expireddate=$((changeperiod + lastupdate)) #" | bc`
if [$alertdate -le $currentdate]; then
echo $username " "`perl -le "print scalar localtime ($expireddate)"` > /home/user3/expireduser.txt
fi
done