|
Search Forums:
|
|||||||
| Forums | Register | Forum Rules | Linux and Unix Links | Man Pages | Albums | FAQ | Users | Calendar | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
|
|
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
Dear Expert, I have made a script for check the expired user and it will send alert if the password will expire less than 8 days. Code:
#!/bin/ksh
# Script for check who will expired the password
#
currentdate=`perl -le 'print time'`
changeperiod=`echo $((84*86400))`
remindperiod=`echo $((8*86400))`
alertperiod=`echo"($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=`echo "$alertperiod + $lastupdate" | bc`
expireddate=`echo "$changeperiode + $lastupdate" | bc`
if [$alertdate -le $currentdate]; then
echo $username " "`perl -le "print scalar localtime ($expireddate)"` > /home/user3/expireduser.txt
fi
donebut the script error. Please help me.... |
| Sponsored Links | |
|
|
|
#2
|
|||
|
|||
|
Quote:
And if you can please pass on the output / error of the script, don't you think it may help the people around to give the solution steadfast? Secondly, I could run the script that you posted above, but the passwd file is not there in my system. Code:
# ls -ltr /etc/security/passwd ls: /etc/security/passwd: No such file or directory |
| Sponsored Links | ||
|
|
|
#3
|
|||
|
|||
|
Quote:
Code:
./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. |
|
#4
|
|||
|
|||
|
Quote:
If that is the case: Code:
# changeperiod=7257600 # remindperiod=691200 # alertperiod=`echo"($changeperiod - $remindperiod)"` -bash: echo(7257600 - 691200): command not found # alertperiod=$((changeperiod - $remindperiod)) # echo $alertperiod 6566400 Secondly, your construct: Code:
expireddate=`echo "$changeperiode + $lastupdate" | bc` Can you see the extra e that is in bold appended to changeperiod variable? That is causing the pain ![]() Hence the error: Code:
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: Code:
#!/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 |
| Sponsored Links | |
|
|
#5
|
|||
|
|||
|
There is work.....thanks a lot.....
|
| Sponsored Links | ||
|
|
![]() |
| Thread Tools | Search this Thread |
| Display Modes | |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| how to write a shellscript to send a mail alert to the website user based on license expiration time | deepu_Shscripts | Shell Programming and Scripting | 0 | 09-03-2010 02:55 AM |
| user expired | murad.jaber | Solaris | 2 | 10-11-2007 04:14 AM |
| How to reactivate expired account in Linux as a root user | cy163 | UNIX for Dummies Questions & Answers | 2 | 05-14-2007 08:46 AM |
| HMC User account expired - What now? | backslash | AIX | 0 | 05-31-2006 05:14 PM |
| Sending a message to a user when password will be expired | Diederd | Security | 1 | 01-28-2002 05:00 PM |
|
|