I am trying to create a script that will take a very large, tab delimited file and then lock accounts.
File headers look like this
id desc server pass sudo lock
test Test user server01 67 no no
"Test user" is under the desc column
Basically if pass column is greater than 60 and lock is no, I need it to ssh to the server in the server column field and lock the account in the id field.
I know i need to use if and awk but I am stumped and running short on time.
Also this needs to be in ksh
---------- Post updated at 09:41 PM ---------- Previous update was at 09:36 PM ----------
Oh ...
ok, i see :
awk -F\\t '(($NF=="no")&&($(NF-2)>60)){print $3,$1}' infile | while read svr uid
do
ssh $svr passwd -l $uid
done
---------- Post updated at 09:48 PM ---------- Previous update was at 09:41 PM ----------
$ cat tst
test01 Test user server01 57 no no
test02 Test user server02 67 no no
test03 Test user server03 57 no no
test04 Test user server04 97 no yes
test05 Test user server05 60 no no
test06 Test user server06 67 no no
test07 Test user server07 88 no no
test08 Test user server08 57 no no
test09 Test user server09 57 no no
test10 Test user server10 99 no no
$ awk -F\\t '(($NF=="no")&&($(NF-2)>60)){print $3,$1}' tst | while read a b; do echo "ssh $a passwd -l $b"; done
ssh server02 passwd -l test02
ssh server06 passwd -l test06
ssh server07 passwd -l test07
ssh server10 passwd -l test10
$
... if you want to run it, just remove the echo part : change