interactive shell script to create users 10.4


 
Thread Tools Search this Thread
Operating Systems OS X (Apple) interactive shell script to create users 10.4
# 1  
Old 03-12-2008
interactive shell script to create users 10.4

Hello everyone,

Not sure if this is the right place, but OS X isn't your standard Unix, so I figured here would be best. I am looking at creating a script that will be interactive that admins can run to create users.

Now, 10.4 uses netinfo database and netinfo manager to handle it's users. So I am looking at writing a script using the niutil command that the admin can input the full name and the short name of the user and the script does the rest. When we migrate to 10.5 I'll have to convert this script over to the dscl command, but I will cross that bridge when I get there.

I am not quite sure how to make it interactive though, my scripting skills are intermediate at best.

Thanks,
# 2  
Old 03-14-2008
Who will be running the interactive user add script? make the script executable by root and no one else. The person issuing the command (launching the script) will need "sudo" privileges, which all local admins accounts have by default.

Here is a page that will help you with the dscl commands:
Porting UNIX/Linux Applications to Mac OS X: Open Directory and the dscl Tool

10.4.x can use dscl too. Might as well use it if you aren't expecting to support the same function in 10.3.

You will basically poll the user for data, and store that data in a variable with the "read" command, for use in making decisions and issuing commands based on the users input.

Some interactive considerations:
echo "Enter a username: "
read username

echo "Add $username? (y/n):
read addflag


Test $addflag, then make the script check if the user already exists. and inform the user if so.

You can use the scripts variable $username where ever a username is required.

Don't take anything for granted. It is possible to add a username to the admin group multiple times, which, while it might not be catastrophic, is very messy. So test, test, test, deploy (but only if you feel it's been tested enough Smilie )
# 3  
Old 03-24-2008
well this is for the very rare case of a non network managed machine which the users would set up local accounts and administer basically them self. However, they have requested an easy way to create and manage their own local user accounts so I was looking at making an interactive script. Which in return after that, I can make it sit on the local admin account's desktop and make an apple script to execute the shell script to make it double click executable. Then all they need to do is input the info in the open terminal screen and exit when finished.

There will be one person with admin rights and the rest of the accounts will be managed.

I have written plenty of simple shell scripts in my time but never one fully interactive, other than a menu based shell script that just ran commands by inputting 1, 2, 3, 4 etc, and 0 to exit. I have never written anything that actually asked for input, and then took that input and inserted it into a script.
# 4  
Old 03-27-2008
For creating a regular user account from the command line interactively, try: Create & delete user accounts from the command line on Mac OS X

Cheers,
verno
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Problems executing an interactive shell script

I am new to Unix shell and to this forum. I am having some trouble executing an interactive shell script that I have written using Mac TextEdit that takes a user input via terminal of a file type (jpg or gif) and then activates a script that will iterate through a folder of unsorted file types... (4 Replies)
Discussion started by: Braveheart
4 Replies

2. Shell Programming and Scripting

Shell Script to filter users and create them again from a back-up server

This is a script to filter the users out of etc/passwd and etc/group. So if you want to migrate of restore a server you can use this script from a backup to restore and make the same users on you had.. Please feedback and comments. #!/bin/bash prompt_list () { # haal uit de argumenten de... (5 Replies)
Discussion started by: dannyvdberg
5 Replies

3. UNIX and Linux Applications

How to write automated interactive shell script?

Hello everyone, I just want to write a shell script for automatic feeding the username and password prompts when running my commands, I tried this one but it did not work. Please help me for any way out. #!/bin/bash #!/usr/bin/expect cd ~/workspace/mimosanetworks_mimosa-nms ls -ltr ... (5 Replies)
Discussion started by: sandy-sm
5 Replies

4. Shell Programming and Scripting

Shell script using an interactive command

Hello experts, I have a to write script for monitoring, the script would use a command and I plan to write the script as follows while true do command -arg sleep 2 clear done The output would be set up on a screen for monitoring. However the issue is that the command used in... (2 Replies)
Discussion started by: maverick_here
2 Replies

5. Shell Programming and Scripting

Use expect to run an interactive shell script?

Hi all, I have a bit of a vexing issue here and I'm not certain how best to go about it. Basically, I want to run a shell script and automate the user prompt of hitting 1 to fully uninstall Symantec Anti-Virus for OS X. Would expect be the best way to do this? (5 Replies)
Discussion started by: prometheon123
5 Replies

6. Homework & Coursework Questions

Help with Interactive / Non Interactive Shell script

Q. Write a script that behaves both in interactive and non interactive mode. When no arguments are supplied it picks up each C program from the directory and prints first 10 lines. It then prompts for deletion of the file. If user supplies arguments with the script , then it works on those files... (1 Reply)
Discussion started by: rits
1 Replies

7. Shell Programming and Scripting

Schedule an interactive shell script

Hi, I need to schedule a shell script which executes another shell script along with a series of other commands. When the inner shell script is executed it prompts for a password..... This inner shell cannot be changed How can I do this???? Regards, Chaitrali. (4 Replies)
Discussion started by: Chaitrali
4 Replies

8. Shell Programming and Scripting

Korn shell interactive script

Hi, How can I prompt a user for two input and pass the input to variables in the script. I have the following script but it is not working: +++++++++Begin+++++++++++ #!/bin/sh database_c=$1 output_f=$2 echo "Your db is $1\nOutput is $2" +++++++++End+++++++++++ Thanks, Leonard (3 Replies)
Discussion started by: leonard905
3 Replies

9. Shell Programming and Scripting

script to create users on many servers

Hi all, working on script to create a user acct on all our servers. for i in `cat $host_file`; do ssh $i /usr/bin/sudo /usr/bin/mkuser id='bpadm' gecos='NetBackup Admin' 2>&1 >> $log done error i get is: 3004-692 Error changing "id" to "bpadm" : Value is invalid. I have tried this in... (1 Reply)
Discussion started by: dnidiffer
1 Replies

10. UNIX for Dummies Questions & Answers

shell scripts to create 100 users

Hello i need a shell script to create 100 users i am running hp-ux......... startegy is something like this craete a shell script !/bin/ksh counter=1 while do { useradd usr$counter passwd usr$counter # here begins my problem when i say passwd usr$counter #it again prompts... (9 Replies)
Discussion started by: xiamin
9 Replies
Login or Register to Ask a Question