You are sending all the output to a single bash shell so only one
command gets executed. You need to figure out a way to execute
the "awk | bash" for each line of users.csv
Something like the following should work
#! /bin/bash
cat users.csv | while read ;
do
echo $REPLY | awk 'BEGIN {FS=","}{print "smbpasswd -a -s
"$1"\n"$3"\n"$3"\n"}' | /bin/bash
done
Jack Mendez wrote:> i am using a script with awk which only works to add the first user from
> my csv file.
> when running with out the -s switch the output seems to be correct using
> echo to test.
>
> here is the script
>
> #!/bin/bash
> cat users.csv |awk 'BEGIN {FS=","}{print "echo smbpasswd
-a -s
> "$1"\n"$3"\n"$3"\n"}' |/bin/bash
>
> this script successfuly adds the first user.
> when using the -s switch.
>
> when i tried this same script with out the -s switch the output is like
this.
> smbpasswd -a username
> then bash complains
> and smbpasswd wants a password
> it does this for each user twice.
> dunno
> any ideas?
>
>