From: Bruce Woodward Date: 2007-03-13T17:48:25+09:00 Subject: Re: perl to ruby ------=_Part_14333_28673546.1173775703463 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline For efficiency, wouldn't using the Etc module would be best? require 'etc' user = ARGV[0] or abort "missing user name" puts (if (Etc.getpwnam(user)).uid >= 1000 `finger #{user}`.gsub(/\n/,"
") else "wal sie na rj....." end) On 3/13/07, Martin DeMello wrote: > > > And in pure ruby, > > id = IO.readlines > ('/etc/passwd').grep(/#{usr}/).first.split(/:/).at(2).to_i > > or for efficiency > > File.open("/etc/passwd", "r") {|f| id = > f.grep(/#{usr}/).first.split(/:/).at(2).to_i} > > > ------=_Part_14333_28673546.1173775703463--