V
Vahid
Hi all;
I am trying to read two files and write the result into the third file
but keep getting "..undefined value as a symbol.." error. Can someone
please tell me what am I doing wrong? Thank you.
#!/usr/bin/perl -w
#
#
#use strict; # if uncomment this, I get many errors.
use warnings;
$ENV{'PATH'} = "/usr/sbin:/sbin:/bin:/usr/bin:/usr/local/bin:";
my $SHADOW = etc_shadow;
my $secSHADOW = sec_passwd;
$|=1;
#
#
#
open (SHADOWfh, "<$SHADOW") || die "Can not open the file: $SHADOW\n";
open (secSHADOWfh, ">$secSHADOW") || die "Can not open the file:
$secSHADOW\n";
my @lines = <SHADOWfh> ;
foreach my $line (@lines) {
my ($username,$pass,$lastchange) = split /:/, $line;
my $sec_lastupdate = ($lastchange*86400);
printf ("%s:\n\tpassword = %s\n\tlastupdate = %d\n\tflags = \n
\n",$username,$pass,$sec_lastupdate); # OK here
printf $secSHADOWfh "%s:\n\tpassword = %s\n\tlastupdate = %d\n
\tflags = \n\n",$username,$pass,$sec_lastupdate; # NOT OK here.
}
close $SHADOWfh;
close $secSHADOWfh;
I am trying to read two files and write the result into the third file
but keep getting "..undefined value as a symbol.." error. Can someone
please tell me what am I doing wrong? Thank you.
#!/usr/bin/perl -w
#
#
#use strict; # if uncomment this, I get many errors.
use warnings;
$ENV{'PATH'} = "/usr/sbin:/sbin:/bin:/usr/bin:/usr/local/bin:";
my $SHADOW = etc_shadow;
my $secSHADOW = sec_passwd;
$|=1;
#
#
#
open (SHADOWfh, "<$SHADOW") || die "Can not open the file: $SHADOW\n";
open (secSHADOWfh, ">$secSHADOW") || die "Can not open the file:
$secSHADOW\n";
my @lines = <SHADOWfh> ;
foreach my $line (@lines) {
my ($username,$pass,$lastchange) = split /:/, $line;
my $sec_lastupdate = ($lastchange*86400);
printf ("%s:\n\tpassword = %s\n\tlastupdate = %d\n\tflags = \n
\n",$username,$pass,$sec_lastupdate); # OK here
printf $secSHADOWfh "%s:\n\tpassword = %s\n\tlastupdate = %d\n
\tflags = \n\n",$username,$pass,$sec_lastupdate; # NOT OK here.
}
close $SHADOWfh;
close $secSHADOWfh;