Operating System - HP-UX
1833276 Members
3089 Online
110051 Solutions
New Discussion

While loop to produce file of invalid user names

 
SOLVED
Go to solution
MarkSyder
Honored Contributor

While loop to produce file of invalid user names

Hi everybody.

Please see the following section of shell script:

/usr/sbin/acct/fwtmp < /var/adm/btmp > /tmp/bad_logins
while read line
do
awk '{print $1}' >> /tmp/bad_login_names
done < /tmp/bad_logins

The first part is creating the file /tmp/bad_logins without any problem but the second part does not put anything into /tmp/bad_login_names.

Any ideas what could be wrong?

Mark Syder (like the drink but spelt different)
The triumph of evil requires only that good men do nothing
4 REPLIES 4
Kent Ostby
Honored Contributor
Solution

Re: While loop to produce file of invalid user names

Not sure , but would this work instead:

awk '{print $1}' < /tmp/bad_logins >> /tmp/bad_login_names

"Well, actually, she is a rocket scientist" -- Steve Martin in "Roxanne"
Victor Fridyev
Honored Contributor

Re: While loop to produce file of invalid user names

Hi Mark.

The script should look like that:
usr/sbin/acct/fwtmp < /var/adm/btmp > /tmp/bad_logins
awk '{print $1}' /tmp/bad_logins >> /tmp/bad_login_names
or
usr/sbin/acct/fwtmp < /var/adm/btmp |
awk '{print $1}'>> /tmp/bad_login_names


HTH
Entities are not to be multiplied beyond necessity - RTFM
Peter Godron
Honored Contributor

Re: While loop to produce file of invalid user names

Mark,
your awk step has no input to process !!
put an
echo $line |
in front of the awk and it should work.
Or use the other solutions given or use cut.
Regards
MarkSyder
Honored Contributor

Re: While loop to produce file of invalid user names

The first two suggestions both worked (I'd assigned points before I saw Peter's suggestion, but always give 3 for people's time even if I don't use their suggestion).

Thanks for the help.

Mark
The triumph of evil requires only that good men do nothing