Hello. I am trying to make this shell script bellow work on my server wich should take the names in newacc.cvs and add them to the system. For each user the script should ask me to enter a password for the user im adding and then add them to the system, however my current solution do not work atm as when i run the script it dont stop to let me enter a password at all at the passwd echo, it just runs past it do someone know how to make this work?
Example from newacc.cvs
maria;jones
andreas;�ring
Script
#!/bin/sh
if [ "$#" == "0" ]
then
cat newacc.cvs | while IFS=';' read firstname surname;
do
useradd $firstname -m
echo added $firstname to the system
passwd $firstname
cd /home/$firstname/
maildirmake.courier Maildir
echo Maildir Created for $firstname
done
exit 0
I tryed to do a read before i did the current "passwd" solution but the same thing happens, it just runs past it not lettning me write anyting
Edit:
I did try it again with read, but as i said erlier it do not stop to let me type in anyting, it just runs the script and then ends, why?
#!/bin/sh
if [ "$#" == "0" ]
then
cat test.cvs | while IFS=';' read firstname surname;
do
#useradd $firstname -m
echo added $firstname to the system
read password
echo $password
cd /home/$firstname/
maildirmake.courier Maildir
echo Maildir Created for $firstname
done
exit 0
fi
Tallgeese:/test# sh -x test.sh
+ '[' 0 == 0 ']'
+ cat test.cvs
+ IFS=';'
+ read firstname surname
+ echo added tobbe to the system
added tobbe to the system
+ read -p 'Enter your password' PASS
+ echo
+ cd /home/tobbe/
+ maildirmake.courier Maildir
test.sh: line 14: maildirmake.courier: kommando hittades inte
+ echo Maildir Created for tobbe
Maildir Created for tobbe
+ IFS=';'
+ read firstname surname
+ exit 0