I am trying to get the equivalent in KSH to work in Perl and I cannot seem to 
get the same output.  I need from /etc/passwd name, uid, gid and gecos for each 
passwd files.
   
  IN KSH:
   
  for i in `ls /var/tmp/passwd.*`
do
   print $i;
   print "\n";
   awk 'FS=":" {print $1,"\t",$3,"\t",$4,"\t",$5}' $i;
   print "\n";
done

  IN PERL
   
  use strict;
  use warnings;
   
  my @array  = glob("/var/tmp/passwd.*");
my ($file,@name,@uid,@gid,@cmts);
  foreach $file (@array) {
   { local $/      = undef;
     open (FILE, "+<$file") or die $!;
     (@name,@uid,@gid,@cmts) = (split /:/, <FILE> ) [0,2,3,4],"\n";
     print ("@name\n");
     print ("@uid\n");
     print ("@gid\n");
     print ("@cmts\n");
   }
}
   
  Perl Output:
  root 0 3
root 0 3 NS2 Root
  root 0 3 tpgdrpp1 Root
...
   
   
  Desired and KSH output :
   
  /var/tmp/passwd.admbakp1.hpux
  
root     0       3
daemon   1       5
bin      2       2
sys      3       3
adm      4       4
uucp     5       3
lp       9       7
nuucp    11      11
hpdb     27      1       ALLBASE
nobody   -2      -2
www      30      1
webadmin         40      1
smbnull          101     101     DO NOT USE OR DELETE - needed by Samba
jgardner         1420    20      xxxxxxxxxxxxxxx
jchow    1516    20      xxxxxxxxxxxxxxx
  jwang    1512    20      xxxxxxxxxxxxxxxxx
ctegarde         1760    20      xxxxxxxxxxx
  sshd     102     102     sshd privsep
rcollins         1640    20      xxxxxxxxxxxxx
dstephen         1515    20
veritas          6352    20      veritas support account
kurathb          103     2017    xxxxxxxxxxxxxxxxxxxxxx
baccelb          2008    2017    xxxxxxxxxxxxxxxxxxxxx
krahnd   224     2017    xxxxxxxxxxxxxxxxx
gladant          510     2017    xxxxxxxxxxxxxxxxx
tyleryo          1948    20      xxxxxxxx
  nguyenhe         1929    20      xxxxxxxxxxxxxx
  patelru          1949    20      xxxxxxxxxxxx
camposi          1950    20      xxxxxxxxxxxxxxxx
brandom          1930    20      xxxxxxxxxx
  panti    1945    20      xxxxxxxxxxx
dwilkins         2037    2017    xxxxxxxxxxx
  hpase    1639    20      HP Support
rdittmer         2168    2017    xxxxxxxxxxxxxx
baxadmin         5000    0
gonzalea         2196    20      xxxxxxxxxxxxxxxx

  /var/tmp/passwd.admsrcp1.hpux
  .
  .
  .
   
   
  thank you
  derek

 __________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

Reply via email to