Bash Script

creating user accounts from file

Page 1 of 1

1 Replies - 701 Views - Last Post: 03 December 2010 - 11:37 AM Rate Topic: -----

#1 FifoK  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 4
  • Joined: 16-November 09

Bash Script

Posted 03 December 2010 - 11:26 AM

Hi there I'm simulating hosting server and I have a question. I have a file called Users.txt and when a user registers this file is appended in the following format - $username:$password . So my goal is to create bash script that reads the file line by line and adds the new Linux users. The code also needs to create a home directory for each user.

So this is what I got by now but something is missing...
#!/bin/bash
IFS.OLD=&IFS
IFS=$'\n'
for entry in `cat /home/student/public_html/Users.txt`
do
	IFS=:
	for i in &entry
	do
		useradd $i -p #I'm not sure how to include the $password here...
	done
done


Thank you for your help!

Is This A Good Question/Topic? 0
  • +

Replies To: Bash Script

#2 JackOfAllTrades  Icon User is offline

  • Saucy!
  • member icon

Reputation: 6039
  • View blog
  • Posts: 23,437
  • Joined: 23-August 08

Re: Bash Script

Posted 03 December 2010 - 11:37 AM

There is no PHP content in this, so I'm going to change the title and move this to Other Languages.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1