|
|||||||
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
#1 |
|
Member (2 bit)
|
Shell Programming script
For my Unix class at school we have to Shell Program. Anyway we have RedHat 7.2 and this is my dilemna:
Create a Shell Script that asks you the following information: last name, first name, primary group, and secondary group. It then adds a the user into the system giving them a default password of '123456' and asks you if you would like to add another person before quitting. Here are some other rules: Comment field =(last,first) username has to be first 5 characters of last name, first 1 character of first. For example, the name Jean Beckerdite the username would be beckej. I would really appreciate the help guys. Thanks in advance! Swizz |
|
|
|
|
|
#2 |
|
Member (8 bit)
Join Date: Jan 2002
Location: Greensboro, NC
Posts: 242
|
Hmmm...not that I could help you if I wanted to as I know nothing about programming, but shouldn't you be doing your own homework?
The Homework Police "FREEZE SUCKA!"
|
|
|
|
|
|
#3 |
|
Member (2 bit)
|
I am getting help with my homework.... The teacher said any help is fine so I go with the best resources. What you said is just dumb.
It's like saying to everyone that posts a message on here "do your own research" or "fix your own problems" so don't go saying "do your own homework" to me because any resource that may be helpful to me in getting my homework done is what I will use. |
|
|
|
|
|
#4 |
|
Member (7 bit)
Join Date: Jul 2000
Location: Australia
Posts: 97
|
Spoon feeding is not a good thing so I'll give you a hint.
This is using bash/sh. Other shell will have a different syntax. Use the useradd utility to add a user. The $1..$9 variables can be used to accept arguments from the command line. $1 will contain the first argument, $2 the second and so on. The $# returns the number arguments passed from the command line. You can create your own variables inside the shell scripts, but remenber not to put any spaces when assigning values to it. e.g. MYVAR="Whatever" echo $MYVAR To get the first n characters from a variable use ${variable : offset : length} e.g. MYVAR="Whatever" ${MYVAR:0:4} will return "What" Concatination is done without any operators. e.g. MYVAR="What" MYVAR2="ever" echo $MAYVAR$MYVAR2 will display "Whatever" When running this shell script you must be root. ( There are ways to do this but running it as root is the easiest ).Because the useradd utility is requires root privilages to work. And finally read a good book, there are plenty of books out there that will help you. Experiment a lot, that is the best way the learn things. Hope this helps. Earlboy |
|
|
|
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|