Hello,

I have a CSV file like:

01,xyz
02,mux
03,mysite
04,mycarsite
05,etcweb

I would like to write a cood the read this csv file and replace the password of the account as such to have formula that contains the numbers above. For example

01,xyz->mypassword01pad
02,mux->mypassword02pad
03,mysite->mypassword03pad
04,mycarsite->mypassword04pad
05,etcweb->mypassword05pad

Thank you

Hello,

I have a CSV file like:

01,xyz
02,mux
03,mysite
04,mycarsite
05,etcweb

I would like to write a cood the read this csv file and replace the password of the account as such to have formula that contains the numbers above. For example

01,xyz->mypassword01pad
02,mux->mypassword02pad
03,mysite->mypassword03pad
04,mycarsite->mypassword04pad
05,etcweb->mypassword05pad

Thank you

...And where have you got stuck? In how to read, or perhaps in how to parse; in how to create the password, or how to deploy the result?
Show us what have you done, and where are you having problems.

Hello,

Actually, I was scared of bash programing to a point I never thought I can do anything; however, your questions made me think and dig deep. Anyhow, here is what I ended up with:

cpwd

#!/bin/bash
INPUT=$1
FORMULA=$2

OLDIFS=$IFS
IFS=,
[ ! -f $INPUT ] && { echo "$INPUT file not found"; exit 99; }
while read index acct
do

       pw=`echo $FORMULA|sed "s/##/$index/g"`
       
      # passwd $acct ?????????
      # Here I want to change each account with $pw

done < $INPUT

IFS=$OLDIFS

csvfile

01,john
02,mike
03,matt

The optimal goal is to type a command like

cpwd [I]filename [/I][I]formula[/I]

Where
filename is the csv file
formula is formula any text with ## such as df!22##9ps. The ## will replace with the index in the csvfile

Now, what I need is to change the password all account on the csvfile using two parameters:

$acct
$pw
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.