Perl endpwent 函数


描述

此函数告诉系统您不再期望使用 getpwent 从密码文件中读取条目。在 Windows 下,使用 Win32API::Net 函数从域服务器获取信息。

句法

以下是该函数的简单语法 -

endpwent

返回值

该函数不返回任何值。

例子

以下是显示其基本用法的示例代码 -

#!/usr/bin/perl

while(($name, $passwd, $uid, $gid, $quota,
   $comment, $gcos, $dir, $shell) = getpwent()) {
   print "Name = $name\n";
   print "Password = $passwd\n";
   print "UID = $uid\n";
   print "GID = $gid\n";
   print "Quota = $quota\n";
   print "Comment = $comment\n";
   print "Gcos = $gcos\n";
   print "HOME DIR = $dir\n";
   print "Shell = $shell\n";
}

setpwent() ; # Rewind the databse /etc/passwd

while(($name, $passwd, $uid, $gid, $quota,
   $comment, $gcos, $dir, $shell) = getpwent()) {
   print "Name = $name\n";
   print "Password = $passwd\n";
   print "UID = $uid\n";
   print "GID = $gid\n";
   print "Quota = $quota\n";
   print "Comment = $comment\n";
   print "Gcos = $gcos\n";
   print "HOME DIR = $dir\n";
   print "Shell = $shell\n";
}

endpwent(); # Closes the database;

执行上述代码时,会产生以下结果 -

Name = root
Password = x
UID = 0
GID = 0
Quota = 
Comment = 
Gcos = root
HOME DIR = /root
Shell = /bin/bash
Name = bin
Password = x
UID = 1
GID = 1
Quota = 
Comment = 
Gcos = bin
HOME DIR = /bin
Shell = /sbin/nologin
Name = daemon
Password = x
UID = 2
GID = 2
Quota = 
Comment = 
Gcos = daemon
HOME DIR = /sbin
Shell = /sbin/nologin
Name = adm
Password = x
UID = 3
GID = 4
Quota = 
Comment = 
Gcos = adm
HOME DIR = /var/adm
Shell = /sbin/nologin
Name = lp
Password = x
UID = 4
GID = 7
Quota = 
Comment = 
Gcos = lp
HOME DIR = /var/spool/lpd
Shell = /sbin/nologin
Name = sync
Password = x
UID = 5
GID = 0
Quota = 
Comment = 
Gcos = sync
HOME DIR = /sbin
Shell = /bin/sync
Name = shutdown
Password = x
UID = 6
GID = 0
Quota = 
Comment = 
Gcos = shutdown
HOME DIR = /sbin
Shell = /sbin/shutdown
Name = halt
Password = x
UID = 7
GID = 0
Quota = 
Comment = 
Gcos = halt
HOME DIR = /sbin
Shell = /sbin/halt
Name = mail
Password = x
UID = 8
GID = 12
Quota = 
Comment = 
Gcos = mail
HOME DIR = /var/spool/mail
Shell = /sbin/nologin
Name = uucp
Password = x
UID = 10
GID = 14
Quota = 
Comment = 
Gcos = uucp
HOME DIR = /var/spool/uucp
Shell = /sbin/nologin
Name = operator
Password = x
UID = 11
GID = 0
Quota = 
Comment = 
Gcos = operator
HOME DIR = /root
Shell = /sbin/nologin
Name = games
Password = x
UID = 12
GID = 100
Quota = 
Comment = 
Gcos = games
HOME DIR = /usr/games
Shell = /sbin/nologin
Name = gopher
Password = x
UID = 13
GID = 30
Quota = 
Comment = 
Gcos = gopher
HOME DIR = /var/gopher
Shell = /sbin/nologin
Name = ftp
Password = x
UID = 14
GID = 50
Quota = 
Comment = 
Gcos = FTP User
HOME DIR = /var/ftp
Shell = /sbin/nologin
Name = nobody
Password = x
UID = 99
GID = 99
Quota = 
Comment = 
Gcos = Nobody
HOME DIR = /
Shell = /sbin/nologin
Name = dbus
Password = x
UID = 81
GID = 81
Quota = 
Comment = 
Gcos = System message bus
HOME DIR = /
Shell = /sbin/nologin
Name = vcsa
Password = x
UID = 69
GID = 69
Quota = 
Comment = 
Gcos = virtual console memory owner
HOME DIR = /dev
Shell = /sbin/nologin
Name = rpc
Password = x
UID = 32
GID = 32
Quota = 
Comment = 
Gcos = Rpcbind Daemon
HOME DIR = /var/cache/rpcbind
Shell = /sbin/nologin
Name = abrt
Password = x
UID = 173
GID = 173
Quota = 
Comment = 
Gcos = 
HOME DIR = /etc/abrt
Shell = /sbin/nologin
Name = apache
Password = x
UID = 48
GID = 48
Quota = 
Comment = 
Gcos = Apache
HOME DIR = /var/www
Shell = /sbin/nologin
Name = saslauth
Password = x
UID = 499
GID = 76
Quota = 
Comment = 
Gcos = "Saslauthd user"
HOME DIR = /var/empty/saslauth
Shell = /sbin/nologin
Name = postfix
Password = x
UID = 89
GID = 89
Quota = 
Comment = 
Gcos = 
HOME DIR = /var/spool/postfix
Shell = /sbin/nologin
Name = qpidd
Password = x
UID = 498
GID = 499
Quota = 
Comment = 
Gcos = Owner of Qpidd Daemons
HOME DIR = /var/lib/qpidd
Shell = /sbin/nologin
Name = haldaemon
Password = x
UID = 68
GID = 68
Quota = 
Comment = 
Gcos = HAL daemon
HOME DIR = /
Shell = /sbin/nologin
Name = ntp
Password = x
UID = 38
GID = 38
Quota = 
Comment = 
Gcos = 
HOME DIR = /etc/ntp
Shell = /sbin/nologin
Name = rpcuser
Password = x
UID = 29
GID = 29
Quota = 
Comment = 
Gcos = RPC Service User
HOME DIR = /var/lib/nfs
Shell = /sbin/nologin
Name = nfsnobody
Password = x
UID = 65534
GID = 65534
Quota = 
Comment = 
Gcos = Anonymous NFS User
HOME DIR = /var/lib/nfs
Shell = /sbin/nologin
Name = tomcat
Password = x
UID = 91
GID = 91
Quota = 
Comment = 
Gcos = Apache Tomcat
HOME DIR = /usr/share/tomcat6
Shell = /sbin/nologin
Name = webalizer
Password = x
UID = 67
GID = 67
Quota = 
Comment = 
Gcos = Webalizer
HOME DIR = /var/www/usage
Shell = /sbin/nologin
Name = sshd
Password = x
UID = 74
GID = 74
Quota = 
Comment = 
Gcos = Privilege-separated SSH
HOME DIR = /var/empty/sshd
Shell = /sbin/nologin
Name = tcpdump
Password = x
UID = 72
GID = 72
Quota = 
Comment = 
Gcos = 
HOME DIR = /
Shell = /sbin/nologin
Name = oprofile
Password = x
UID = 16
GID = 16
Quota = 
Comment = 
Gcos = Special user account to be used by OProfile
HOME DIR = /home/oprofile
Shell = /sbin/nologin
Name = amrood
Password = x
UID = 500
GID = 500
Quota = 
Comment = 
Gcos = 
HOME DIR = /home/amrood
Shell = /bin/bash
Name = mailnull
Password = x
UID = 47
GID = 47
Quota = 
Comment = 
Gcos = 
HOME DIR = /var/spool/mqueue
Shell = /sbin/nologin
Name = smmsp
Password = x
UID = 51
GID = 51
Quota = 
Comment = 
Gcos = 
HOME DIR = /var/spool/mqueue
Shell = /sbin/nologin
Name = mysql
Password = x
UID = 27
GID = 27
Quota = 
Comment = 
Gcos = MySQL Server
HOME DIR = /var/lib/mysql
Shell = /bin/bash
Name = named
Password = x
UID = 25
GID = 25
Quota = 
Comment = 
Gcos = Named
HOME DIR = /var/named
Shell = /sbin/nologin
Name = qemu
Password = x
UID = 107
GID = 107
Quota = 
Comment = 
Gcos = qemu user
HOME DIR = /
Shell = /sbin/nologin
Name = com
Password = x
UID = 501
GID = 501
Quota = 
Comment = 
Gcos = 
HOME DIR = /home/com
Shell = /bin/bash
Name = railo
Password = x
UID = 497
GID = 495
Quota = 
Comment = 
Gcos = 
HOME DIR = /opt/railo
Shell = /bin/false
Name = root
Password = x
UID = 0
GID = 0
Quota = 
Comment = 
Gcos = root
HOME DIR = /root
Shell = /bin/bash
Name = bin
Password = x
UID = 1
GID = 1
Quota = 
Comment = 
Gcos = bin
HOME DIR = /bin
Shell = /sbin/nologin
Name = daemon
Password = x
UID = 2
GID = 2
Quota = 
Comment = 
Gcos = daemon
HOME DIR = /sbin
Shell = /sbin/nologin
Name = adm
Password = x
UID = 3
GID = 4
Quota = 
Comment = 
Gcos = adm
HOME DIR = /var/adm
Shell = /sbin/nologin
Name = lp
Password = x
UID = 4
GID = 7
Quota = 
Comment = 
Gcos = lp
HOME DIR = /var/spool/lpd
Shell = /sbin/nologin
Name = sync
Password = x
UID = 5
GID = 0
Quota = 
Comment = 
Gcos = sync
HOME DIR = /sbin
Shell = /bin/sync
Name = shutdown
Password = x
UID = 6
GID = 0
Quota = 
Comment = 
Gcos = shutdown
HOME DIR = /sbin
Shell = /sbin/shutdown
Name = halt
Password = x
UID = 7
GID = 0
Quota = 
Comment = 
Gcos = halt
HOME DIR = /sbin
Shell = /sbin/halt
Name = mail
Password = x
UID = 8
GID = 12
Quota = 
Comment = 
Gcos = mail
HOME DIR = /var/spool/mail
Shell = /sbin/nologin
Name = uucp
Password = x
UID = 10
GID = 14
Quota = 
Comment = 
Gcos = uucp
HOME DIR = /var/spool/uucp
Shell = /sbin/nologin
Name = operator
Password = x
UID = 11
GID = 0
Quota = 
Comment = 
Gcos = operator
HOME DIR = /root
Shell = /sbin/nologin
Name = games
Password = x
UID = 12
GID = 100
Quota = 
Comment = 
Gcos = games
HOME DIR = /usr/games
Shell = /sbin/nologin
Name = gopher
Password = x
UID = 13
GID = 30
Quota = 
Comment = 
Gcos = gopher
HOME DIR = /var/gopher
Shell = /sbin/nologin
Name = ftp
Password = x
UID = 14
GID = 50
Quota = 
Comment = 
Gcos = FTP User
HOME DIR = /var/ftp
Shell = /sbin/nologin
Name = nobody
Password = x
UID = 99
GID = 99
Quota = 
Comment = 
Gcos = Nobody
HOME DIR = /
Shell = /sbin/nologin
Name = dbus
Password = x
UID = 81
GID = 81
Quota = 
Comment = 
Gcos = System message bus
HOME DIR = /
Shell = /sbin/nologin
Name = vcsa
Password = x
UID = 69
GID = 69
Quota = 
Comment = 
Gcos = virtual console memory owner
HOME DIR = /dev
Shell = /sbin/nologin
Name = rpc
Password = x
UID = 32
GID = 32
Quota = 
Comment = 
Gcos = Rpcbind Daemon
HOME DIR = /var/cache/rpcbind
Shell = /sbin/nologin
Name = abrt
Password = x
UID = 173
GID = 173
Quota = 
Comment = 
Gcos = 
HOME DIR = /etc/abrt
Shell = /sbin/nologin
Name = apache
Password = x
UID = 48
GID = 48
Quota = 
Comment = 
Gcos = Apache
HOME DIR = /var/www
Shell = /sbin/nologin
Name = saslauth
Password = x
UID = 499
GID = 76
Quota = 
Comment = 
Gcos = "Saslauthd user"
HOME DIR = /var/empty/saslauth
Shell = /sbin/nologin
Name = postfix
Password = x
UID = 89
GID = 89
Quota = 
Comment = 
Gcos = 
HOME DIR = /var/spool/postfix
Shell = /sbin/nologin
Name = qpidd
Password = x
UID = 498
GID = 499
Quota = 
Comment = 
Gcos = Owner of Qpidd Daemons
HOME DIR = /var/lib/qpidd
Shell = /sbin/nologin
Name = haldaemon
Password = x
UID = 68
GID = 68
Quota = 
Comment = 
Gcos = HAL daemon
HOME DIR = /
Shell = /sbin/nologin
Name = ntp
Password = x
UID = 38
GID = 38
Quota = 
Comment = 
Gcos = 
HOME DIR = /etc/ntp
Shell = /sbin/nologin
Name = rpcuser
Password = x
UID = 29
GID = 29
Quota = 
Comment = 
Gcos = RPC Service User
HOME DIR = /var/lib/nfs
Shell = /sbin/nologin
Name = nfsnobody
Password = x
UID = 65534
GID = 65534
Quota = 
Comment = 
Gcos = Anonymous NFS User
HOME DIR = /var/lib/nfs
Shell = /sbin/nologin
Name = tomcat
Password = x
UID = 91
GID = 91
Quota = 
Comment = 
Gcos = Apache Tomcat
HOME DIR = /usr/share/tomcat6
Shell = /sbin/nologin
Name = webalizer
Password = x
UID = 67
GID = 67
Quota = 
Comment = 
Gcos = Webalizer
HOME DIR = /var/www/usage
Shell = /sbin/nologin
Name = sshd
Password = x
UID = 74
GID = 74
Quota = 
Comment = 
Gcos = Privilege-separated SSH
HOME DIR = /var/empty/sshd
Shell = /sbin/nologin
Name = tcpdump
Password = x
UID = 72
GID = 72
Quota = 
Comment = 
Gcos = 
HOME DIR = /
Shell = /sbin/nologin
Name = oprofile
Password = x
UID = 16
GID = 16
Quota = 
Comment = 
Gcos = Special user account to be used by OProfile
HOME DIR = /home/oprofile
Shell = /sbin/nologin
Name = amrood
Password = x
UID = 500
GID = 500
Quota = 
Comment = 
Gcos = 
HOME DIR = /home/amrood
Shell = /bin/bash
Name = mailnull
Password = x
UID = 47
GID = 47
Quota = 
Comment = 
Gcos = 
HOME DIR = /var/spool/mqueue
Shell = /sbin/nologin
Name = smmsp
Password = x
UID = 51
GID = 51
Quota = 
Comment = 
Gcos = 
HOME DIR = /var/spool/mqueue
Shell = /sbin/nologin
Name = mysql
Password = x
UID = 27
GID = 27
Quota = 
Comment = 
Gcos = MySQL Server
HOME DIR = /var/lib/mysql
Shell = /bin/bash
Name = named
Password = x
UID = 25
GID = 25
Quota = 
Comment = 
Gcos = Named
HOME DIR = /var/named
Shell = /sbin/nologin
Name = qemu
Password = x
UID = 107
GID = 107
Quota = 
Comment = 
Gcos = qemu user
HOME DIR = /
Shell = /sbin/nologin
Name = com
Password = x
UID = 501
GID = 501
Quota = 
Comment = 
Gcos = 
HOME DIR = /home/com
Shell = /bin/bash
Name = railo
Password = x
UID = 497
GID = 495
Quota = 
Comment = 
Gcos = 
HOME DIR = /opt/railo
Shell = /bin/false
perl_function_references.htm