Quote:
Originally Posted by osor
Probably because I forgot to specify gawk (which has the ARGIND variable). There was also a typo I fixed.
If you want to use nawk, the following should work (I put in some comments):
Code:
#!/usr/bin/awk
FNR==1 { # when we encounter line 1 of a file
FS=OFS= arg++ ? " " : ";" # arg = 1 for first file, 2 for second
"date +%Y/%m/%d" | getline now
}
arg==1 {
if ($6<now && $4==1)
$4 = 0
enabled[$1] = $4 # record the enabled status of this username
print $0 > usersDB.conf
}
arg==2 { print (enabled[$2] ? "" : "#") $0 > access.conf }
You were correct in how to run it:
Code:
./scritpt.awk usersDB.conf access.conf
|
Your script is working fine except when i run it twice it deactivate already deactivated users i mean it add # to "#F: username" in the access.conf file. is it possible to ignore the already deactivated users in the access.conf file.
#!/usr/bin/gawk -f
FNR==1 { # when we encounter line 1 of a file
FS=OFS= arg++ ? " " : ";" # arg = 1 for first file, 2 for second
"date +%Y/%m/%d" | getline now
}
arg==1 {
if ($6<now && $4==1)
$4 = 0
enabled[$1] = $4 # record the enabled status of this username
print $0 > "usersDB.conf"
}
arg==2 { print (enabled[$2] ? "" : "#") $0 > "access.conf" }
thanks a lot.