The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > OS Specific Forums > OS X (Apple)
Google UNIX.COM


OS X (Apple) OS X is a line of Unix-based graphical operating systems developed, marketed, and sold by Apple.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Schedule an interactive shell script Chaitrali Shell Programming and Scripting 4 11-08-2007 07:49 AM
Korn shell interactive script leonard905 Shell Programming and Scripting 3 08-02-2007 11:16 AM
How to hide user inputted text for interactive unix shell script? patrickpang Shell Programming and Scripting 1 04-04-2006 05:42 PM
script to create users on many servers dnidiffer Shell Programming and Scripting 1 09-24-2005 11:32 PM
shell scripts to create 100 users xiamin UNIX for Dummies Questions & Answers 9 09-06-2001 10:47 PM

Reply
 
Submit Tools LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 03-12-2008
Registered User
 

Join Date: Mar 2008
Posts: 10
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit! Stumble this Post!Spurl this Post!
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,
Reply With Quote
Forum Sponsor
  #2 (permalink)  
Old 03-14-2008
Registered User
 

Join Date: Sep 2002
Location: San Fran
Posts: 105
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit! Stumble this Post!Spurl this Post!
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 )
Reply With Quote
  #3 (permalink)  
Old 03-24-2008
Registered User
 

Join Date: Mar 2008
Posts: 10
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit! Stumble this Post!Spurl this Post!
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.
Reply With Quote
  #4 (permalink)  
Old 03-27-2008
Registered User
 

Join Date: Sep 2006
Posts: 11
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit! Stumble this Post!Spurl this Post!
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
Reply With Quote
Google UNIX.COM
Reply

Thread Tools
Display Modes


The 50 most popular UNIX and Linux searches.
Google Search Cloud for The UNIX and Linux Forums
421 service not available, remote server has closed connection ^m automate ftp autosys awk trim bash eval bash for loop boot: cannot open kernel/sparcv9/unix command copy/move folder in unix curses.h cut command in unix daemon process find grep find mtime find null character in a unix file from ip can we get machine name +unix glance unix grep multiple lines grep or grep recursive how to redirect console logs in unix inaddr_any inappropriate ioctl for device lynx javascript mailx attachment mget mtime perl array length ping port remove first character from string in k shell replace space by comma , perl script scp recursive segmentation fault(coredump) sftp script snoop unix stale nfs file handle syn_sent tar exclude tar extract to folder unix unix .profile unix forum unix forums unix internals unix interview questions unix mtime unix simulator unix.com vi substitute while loop within while loop shell script


All times are GMT -7. The time now is 11:49 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008 The CEP Blog All Rights Reserved -Ad Management by RedTyger Visit The Global Fact Book

Content Relevant URLs by vBSEO 3.2.0

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101