convert a sql-account-table to a real passwd-list

step1 : create and check the output

 echo 'select uid,login,plainpass from accounts' | psql -U peter accounts | perl -ne 'print "useradd -u $1 -g 101 -p $3 -s /bin/false -d /dev/null $2\n" if /^\s+(\d+)\s+\|\s+(\S+)\s+\|\s+(\S+)/' 

step2 : create and perform the output

 echo 'select uid,login,plainpass from accounts' | psql -U peter accounts | perl -ne 'print "useradd -u $1 -g 101 -p $3 -s /bin/false -d /dev/null $2\n" if /^\s+(\d+)\s+\|\s+(\S+)\s+\|\s+(\S+)/' | bash
 
knowwiki/shorties/sql_to_passwd.txt · Last modified: 2008/06/23 23:48 by peter