免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 1873 | 回复: 0
打印 上一主题 下一主题

[新手入门] AIX下,得到用户上次更改密码时间的脚本(原创) [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2005-03-21 12:39 |只看该作者 |倒序浏览
AIX下,得到用户上次更改密码时间的脚本(原创)
AIX下,得到用户上次更改密码时间的脚本(原创)
    看了这个帖子:
[color="#336699"]http://www.loveunix.net/bbs/index.php?showtopic=42654
,于是决定自己写了个得到用户上次更改密码时间的脚本。第一次用PERL写脚本,所以花的时间不短,但是从中学到很多东西,很是欣慰。
脚本如下:
#!/usr/bin/perl
# script name: lastupdate
# function: get the last password update time of some account in AIX
# usage: lastupdate USERNAME
# author:
[color="#336699"]beginner@yeah.net

[color="#336699"]http://blog.chinaunix.net/index.php?blogId=739
if ($ARGV[0]) {
print "The corrent time is:[color="#ff0000"]ttt";
#system (date);
print scalar localtime(time);
print "[color="#ff0000"]n";
$lastup=`cat /etc/security/passwd |grep -p $ARGV[0] |grep lastup |awk '{print }'`;
print "The last update time of $ARGV[0] is:[color="#ff0000"]t";
print scalar localtime($lastup);
print "[color="#ff0000"]n";
} else {
print " usage: [path] lastupdate USERNAME[color="#ff0000"]n";
}
脚本名叫lastupdate,chmod +x lastupdate之后就可以用了。
实验结果如下:
mycomputer#> ./lastupdate root
The corrent time is:                        Thu Jan 27 10:58:24  2005
The last update time of root is:        Mon Dec 27 08:30:11 2004
mycomputer#>
补充说明:由于网页的原因,脚本中print语句的“\t”和“\n”(红字表示)被自动替换成了“t”和“n”,这可能是BLOG的BUG。


本文来自ChinaUnix博客,如果查看原文请点:http://blog.chinaunix.net/u/5262/showart_16791.html
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP