Mailinglist Archive: opensuse (4498 mails)

< Previous Next >
Re: [opensuse] awk/bash for password generation
  • From: Anders Johansson <andjoh@xxxxxxxxxx>
  • Date: Wed, 15 Nov 2006 01:57:02 +0100
  • Message-id: <200611150157.02606.andjoh@xxxxxxxxxx>
On Wednesday 15 November 2006 01:55, Anders Johansson wrote:
> On Wednesday 15 November 2006 00:33, Kevin Donnelly wrote:
> > I have a list of usernames and passwords in a csv file, and what I'm
> > trying to do is loop through each user, run the password through
> > htpasswd, and write both to a file for Apache directory restriction.
> >
> > The usernames and passwords are in fields 9 and 10 of the file
> > respectively, and I was trying to do the loop via:
> > for user in $(awk 'BEGIN { FS = ";" } ; {print $9}' user_pw.csv)
> > do
> > password="awk 'BEGIN { FS = ";" } ; {print $10}' user_pw.csv)
> > echo "User $user has password $password"
> > done
> > But that gives an error:
> > bash: syntax error near unexpected token `" } ; {print $10}'
> > user_pw.csv"' I've tried escaping the ";" in different ways, but none of
> > them seem to work.
> >
> > Can anyone suggest a way to get bash to do what I want?
>
> declare -a foo
>
> while IFS=':' read -a foo; do
> echo user ${foo[8]} has password ${foo[9]}
> done

oops, forgot to actually read something. How about

declare -a foo
while IFS=':' read -a foo; do
echo user ${foo[8]} has password ${foo[9]}
done < user_pw.csv
---------------------------------------------------------------------
To unsubscribe, e-mail: opensuse+unsubscribe@xxxxxxxxxxxx
For additional commands, e-mail: opensuse+help@xxxxxxxxxxxx

< Previous Next >
Follow Ups