Sponsored Content
Top Forums Shell Programming and Scripting perl :Changing script to only find the group Post 302709023 by rdrtx1 on Tuesday 2nd of October 2012 02:20:37 PM
Old 10-02-2012
Code:
 
#!/usr/bin/perl
use strict;
use POSIX qw(ceil);
use User::pwent;
use Term::ANSIColor;

my ($user,%userids);
my $gid = getgrnam ("support");


while ($user = getpwent()){
        next if ($user->gid != $gid);
        my $u = $user->name;
        if ( `lsuser -a account_locked $u` =~ /.*account_locked=true.*/) {next;}

        chomp(my $lastupdate = `lssec -f /etc/security/passwd -a lastupdate -s $u | awk -F= '{print \$2}'`);
        if (! $lastupdate) { next; }  

        chomp(my $maxage = `lsuser -a maxage $u | awk -F= '{print \$2}'` * 7);

        my $expires = $lastupdate + (60 * 60 * 24 * $maxage);
        my $expire_date = scalar(localtime($expires));
        my $change_date = scalar(localtime($lastupdate));
        my $now = time();
        my $daysremaining = ceil((($expires - $now) / (60*60*24)) - 1);

        push(@{$userids{$u}}, $daysremaining,$maxage,$change_date,$expire_date);
}

print "User         DaysLeft  Expires                   LastChanged               DaysValid\n";

foreach $user (sort {$userids{$a}[0] <=> $userids{$b}[0] } keys %userids){
        if (@{$userids{$user}}[0] <= 0) { 
                print color("red");
        }elsif(@{$userids{$user}}[0] <= 14){
                print color("yellow");
        }else{
                print color ("green");
        }

        printf "%-12s %-9d %-26s", $user, @{$userids{$user}}[0], @{$userids{$user}}[3]; 
        printf "%-25s %-9d\n", @{$userids{$user}}[2], @{$userids{$user}}[1];
        print color ("reset");
}

This User Gave Thanks to rdrtx1 For This Post:
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Perl script - changing passwords

Just wanted options of this - first 'real' Perl script and I'm not positive of all the quirks in Perl. Any suggestions are welcome. Especially since I'm messing with /etc/shadow! Running Solaris 2.6, Perl 5.005.03 #!/u/bin/perl # # Change the user's old password to the new in /etc/shadow ... (3 Replies)
Discussion started by: thehoghunter
3 Replies

2. UNIX for Dummies Questions & Answers

Changing the Effective Group ID

Here is my situation. On a RedHat 7.3 box, I have a user named jody. When I log in with jody and type in "id", I get the expected output: uid=1(jody) gid=1(jody) groups=1(jody), 510(test) However, I cannot figure which "id" option allows me to change the effective gid. I tried the options... (2 Replies)
Discussion started by: Jody
2 Replies

3. UNIX for Advanced & Expert Users

File group ownership changing automatically

Hi everyone, Need help with an issue. The group ownership of files on my Solaris system is getting changed automatically. Could someone tell me the reason why? And how could I correct it? One more info- everytime the ownership changes, it changes to "x". Thanks :confused: (1 Reply)
Discussion started by: top_gun
1 Replies

4. Filesystems, Disks and Memory

changing group ID

My current GID are all < 100, however I am having issues now with this. Does anyone know of a way to change all GID's to perhaps add 100, IE so GID now = 23 will = 123. I am running an NIS network so changing the table is easy , however finding all the files on all my filesystems and modifying... (4 Replies)
Discussion started by: frankkahle
4 Replies

5. Shell Programming and Scripting

Changing userID and Changing group and GID

Hello, I want to write a ksh script about changing UID and changing group with GID. There are multiple servers i want to perform that job. linux1 linux2 linux3 linux4 linux5 ...... . . . . . 1.) How can i enter "password" in script rather asking me? I was trying this... ssh... (2 Replies)
Discussion started by: deal732
2 Replies

6. Shell Programming and Scripting

Find all files with group read OR group write OR user write permission

I need to find all the files that have group Read or Write permission or files that have user write permission. This is what I have so far: find . -exec ls -l {} \; | awk '/-...rw..w./ {print $1 " " $3 " " $4 " " $9}' It shows me all files where group read = true, group write = true... (5 Replies)
Discussion started by: shunter63
5 Replies

7. Solaris

Changing root group to group from other

Does any one know if changing root's group from “other” to “root” will cause any problems on a running system. Thanks (4 Replies)
Discussion started by: mjkroner
4 Replies

8. Shell Programming and Scripting

changing from command line to perl script

I had posted previously about this problem I had. I have multiple text files with hundreds of lines of the following type: 2000001 34 54 234 2000001 32 545 2000001 -2000001 77 2000001 44 2000001 998 2000001 77 32 2000001 45 23 111 89 98 75 23 34 999 . . . etc... What I wanted was... (2 Replies)
Discussion started by: xchen89x
2 Replies

9. UNIX for Dummies Questions & Answers

regarding changing ownership and group

i am able to change the mode using chmod and able to change permission. but i am not able to change group and ownership. getting as invalid can any one help me regarding this . (4 Replies)
Discussion started by: satheeshkr_cse
4 Replies

10. UNIX for Dummies Questions & Answers

Changing rights without touching user and group?

Hello, I have a small problem and would be happy if someone could help me to find a solution: A machine ("server") makes backups of different computers ("clients") using rsync. Users and groups are keept, so that it's possible to copy them back to the client if required. The number of groups... (3 Replies)
Discussion started by: tracer
3 Replies
DELIVER(8)						      System Manager's Manual							DELIVER(8)

 *

NAME
deliver - deliver mail to an IMAP mailbox SYNOPSIS
deliver [ -C config-file ] [ -d ] [ -r address ] [ -f address ] [ -m mailbox ] [ -a auth-id ] [ -q ] [ userid ]... deliver [ -C config-file ] -l DESCRIPTION
Deliver reads a message from the standard input and delivers it to one or more IMAP mailboxes. Deliver reads its configuration options out of the imapd.conf(5) file unless specified otherwise by -C. OPTIONS
-C config-file Read configuration options from config-file. -d Ignored for compatability with /bin/mail. -r address Insert a Return-Path: header containing address -f address Insert a Return-Path: header containing address -m mailbox Deliver to mailbox. If any userids are specified, attempts to deliver to user.userid.mailbox for each userid. If the ACL on any such mailbox does not grant the sender the "p" right or if -m is not specified, then delivers to the INBOX for the userid, regard- less of the ACL on the INBOX. If no userids are specified, attempts to deliver to mailbox. If the ACL on mailbox does not grant the sender the "p" right, the delivery fails. -a auth-id Specify the authorization id of the sender. Defaults to "anonymous". -q Deliver message even when receiving mailbox is over quota. -l Accept messages using the LMTP protocol. NOTES
Depending on the setting of reject8bit in imapd.conf(5), deliver either rejects/accepts messages with 8-bit-set characters in the headers. If we accept messages with 8-bit-set characters in the headers, then depending on the setting of munge8bit, these characters are either left un-touched or changed to `X'. This is because such characters can't be interpreted since the character set is not known, although some communities not well-served by US-ASCII assume that those characters can be used to represent characters not present in US-ASCII. A method for encoding 8-bit-set characters is provided by RFC 2047. FILES
/etc/imapd.conf SEE ALSO
lmtpd(8) CMU
Project Cyrus DELIVER(8)
All times are GMT -4. The time now is 03:00 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy