Sponsored Content
Full Discussion: Expired user alert
Top Forums Shell Programming and Scripting Expired user alert Post 302596285 by knight_eon on Tuesday 7th of February 2012 04:52:34 AM
Old 02-07-2012
Quote:
Originally Posted by michlix
the error is
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.

Are you trying to compute the difference in alertperiod=`echo"($changeperiod - $remindperiod)"`
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 Smilie

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

 

6 More Discussions You Might Find Interesting

1. Cybersecurity

Sending a message to a user when password will be expired

Hi, Does anyone have a script (for AIX) that sends a message to a user that his password will be expired within 5 days for ex. Thanks (1 Reply)
Discussion started by: Diederd
1 Replies

2. AIX

HMC User account expired - What now?

I've created an hmc user account for our developers and set a pawword expiry to 30 days. Trouble is when the password expires they are asked to change it in the WebSM gui but it returns an error "XXXX check log file /var/websm/data/....log" which doesn't exist. I've tried resetting the password... (0 Replies)
Discussion started by: backslash
0 Replies

3. UNIX for Dummies Questions & Answers

How to reactivate expired account in Linux as a root user

I am an administrator of a Red Hat Enterprise Linux system. Now one account expired. I wonder how to reactivate the account. Thanks (2 Replies)
Discussion started by: cy163
2 Replies

4. Solaris

user expired

dear all iam trying to make user expire and it not suceeded with me iam trying useradd -e and it not succeeded (2 Replies)
Discussion started by: murad.jaber
2 Replies

5. Shell Programming and Scripting

Finding AIX user accounts expired or locked

// AIX 6.1 In need of finding which AIX user accounts will be expired and are locked. I have placed the following parameters under /etc/security/user... (1 Reply)
Discussion started by: Daniel Gate
1 Replies

6. Solaris

Solaris 11 user account login expired

Hi everyone Please i need urgent help... I have installed solaris 11 using live media.. then i installed sunray.. every thing is fine.. but after system reboot i am unable to login on server on GUI it gives account expired error or some time authentication failed... but i can log in through... (11 Replies)
Discussion started by: amk
11 Replies
port_alert(3C)						   Standard C Library Functions 					    port_alert(3C)

NAME
port_alert - set a port in alert mode SYNOPSIS
#include <port.h> int port_alert(int port, int flags, int events, void *user); DESCRIPTION
The port_alert() function transitions a port into or out of alert mode. A port in alert mode immediately awakens all threads blocked in port_get(3C) or port_getn(3C). These threads return with an alert notification that consists of a single port_event_t structure with the source PORT_SOURCE_ALERT. Subsequent threads trying to retrieve events from a port that is in alert mode will return immediately with the alert notification. A port is transitioned into alert mode by calling the port_alert() function with a non-zero events parameter. The specified events and user parameters will be made available in the portev_events and the portev_user members of the alert notification, respectively. The flags argument determines the mode of operation of the alert mode: o If flags is set to PORT_ALERT_SET, port_alert() sets the port in alert mode independent of the current state of the port. The portev_events and portev_user members are set or updated accordingly. o If flags is set to PORT_ALERT_UPDATE and the port is not in alert mode, port_alert() transitions the port into alert mode. The portev_events and portev_user members are set accordingly. o If flags is set to PORT_ALERT_UPDATE and the port is already in alert mode, port_alert() returns with an error value of EBUSY. PORT_ALERT_SET and PORT_ALERT_UPDATE are mutually exclusive. A port is transitioned out of alert mode by calling the port_alert() function with a zero events parameter. Events can be queued to a port that is in alert mode, but they will not be retrievable until the port is transitioned out of alert mode. RETURN VALUES
Upon succesful completion, 0 is returned. Otherwise, -1 is returned and errno is set to indicate the error. ERRORS
The port_alert() function will fail if: EBADF The port identifier is not valid. EBADFD The port argument is not an event port file descriptor. EBUSY The port is already in alert mode. EINVAL Mutually exclusive flags are set. ATTRIBUTES
See attributes(5) for descriptions of the following attributes: +-----------------------------+-----------------------------+ | ATTRIBUTE TYPE | ATTRIBUTE VALUE | +-----------------------------+-----------------------------+ |Architecture |all | +-----------------------------+-----------------------------+ |Availability |SUNWcsr, SUNWhea | +-----------------------------+-----------------------------+ |Interface Stability |Evolving | +-----------------------------+-----------------------------+ |MT-Level |Safe | +-----------------------------+-----------------------------+ SEE ALSO
port_associate(3C), port_create(3C), port_get(3C), port_send(3C), attributes(5) SunOS 5.10 1 Oct 2003 port_alert(3C)
All times are GMT -4. The time now is 11:09 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy