LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 09-09-2006, 09:17 AM   #1
number_8
LQ Newbie
 
Registered: Sep 2006
Posts: 2

Rep: Reputation: 0
Need Some Shell Scripting Help


Hi all

i just need some help trying to create a script that will automatically create users from an input text file, but i have no idea how i should implement the input into my script

this is an example of the input text file

Title FirstName LastName
Mr Jim Black

Thanks in advance
 
Old 09-09-2006, 09:39 AM   #2
PTrenholme
Senior Member
 
Registered: Dec 2004
Location: Olympia, WA, USA
Distribution: Fedora, (K)Ubuntu
Posts: 4,187

Rep: Reputation: 354Reputation: 354Reputation: 354Reputation: 354
Look in info bash under readline in the function section. Also, look at the cut and sed commands for help in parsing the lines.

If you want an easier way to handle your problem, look at info gawk (especially the examples section).
 
Old 09-09-2006, 06:49 PM   #3
/bin/bash
Senior Member
 
Registered: Jul 2003
Location: Indiana
Distribution: Mandrake Slackware-current QNX4.25
Posts: 1,802

Rep: Reputation: 47
Just a quickie example of reading input from a file.

Code:
$ cat file
Mr Jim Black
Mrs Jane Doe
last last last


$ cat doit
#!/bin/bash
while [ true ];do #endless loop
  read TITLE FIRST LAST
  if [ $TITLE = "last" ];then
    break # jump out of loop
  fi
  # Create user account here
  echo "Created Account for $TITLE $FIRST $LAST"
done <file

$ ./doit
Created Account for Mr Jim Black
Created Account for Mrs Jane Doe
 
Old 09-10-2006, 12:49 AM   #4
number_8
LQ Newbie
 
Registered: Sep 2006
Posts: 2

Original Poster
Rep: Reputation: 0
thanks for the help people
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Shell Scripting: Getting a pid and killing it via a shell script topcat Programming 15 10-28-2007 02:14 AM
teaching shell scripting: cool scripting examples? fax8 Linux - General 1 04-20-2006 04:29 AM
shell interface vs shell scripting? I'm confused jcchenz Linux - Software 1 10-26-2005 03:32 PM
shell scripting s_shenbaga Linux - Newbie 2 05-05-2005 05:12 AM
Shell Scripting - Need some help The Grepper Programming 1 03-29-2002 04:10 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 06:04 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration