Go Back   PCMech Forums > Help & Discussion > Web Design / Development

Need Some Help? Type Your Keywords Here:

Reply
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
Old 02-12-2002, 02:33 PM   #1
Member (2 bit)
 
Join Date: Feb 2002
Location: Green Bay, WI
Posts: 3
Send a message via AIM to djswizz Send a message via Yahoo to djswizz
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
djswizz is offline   Reply With Quote
Old 02-12-2002, 04:06 PM   #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!"

Jason Padgett is offline   Reply With Quote
Old 02-12-2002, 04:16 PM   #3
Member (2 bit)
 
Join Date: Feb 2002
Location: Green Bay, WI
Posts: 3
Send a message via AIM to djswizz Send a message via Yahoo to djswizz
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.
djswizz is offline   Reply With Quote
Old 02-15-2002, 08:54 PM   #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
earlboy is offline   Reply With Quote
Reply

Bookmarks

Still Need Help? Type Your Keywords Here:


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

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 On
HTML code is On
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT -5. The time now is 07:51 AM.
Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2012, vBulletin Solutions, Inc.
SEO by vBSEO 3.6.0 PL2