Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

simple shell script question

Status
Not open for further replies.

Jasen

IS-IT--Management
May 1, 2002
435
US
I'd like to create a simple script where I can easily create a new user, set them to a specific group, and set their password, all in one command.
something like

$ myscript newuser userpass

inside of "myscript" I'll just have pw useradd and etc.
The question is, how do I specify the arguments inside the script?
For instance, in a DOS batch file you'd use %1 for the first argument given. So inside the script you'd place %1 everywhere you want the first argument to be. What's the syntax for doing this in a shell script? I'm using csh, or bash, depending.

The second half of the question is, how can I pass the password to passwd so it doesn't ask. I thought maybe doing something like
echo newpass | passwd user
would work, but it does not.

I'm using a FreeBSD system, btw.

________
Remember, you're unique... just like everyone else.
 
For BASH it's $1, $2 etc. instead of % in DOS. Not sure about csh.

No sure if you could script the passwd bit, it is an interactive command. You may need to use Expect to do that for you.

IBM Certified Confused - MQSeries
IBM Certified Flabbergasted - AIX 5 pSeries System Administration
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top