nixCraft Linux Forum

nixCraft

Linux / UNIX Tech Support Forum

Shell menu script to adduser

This is a discussion on Shell menu script to adduser within the Shell scripting forums, part of the Development/Scripting category; hi everyone i'm new to linux and needing a bit of help with a script this script is to create ...


Go Back   nixCraft Linux Forum > Development/Scripting > Shell scripting

Linux answers from nixCraft.


Shell scripting You can discuss the shell scripting, request shell scripts and scripting techniques

Reply

 

LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 04-05-2009, 10:24 PM
Junior Member
User
 
Join Date: May 2009
OS: pclinux, Ubuntu
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Power: 0
newgeek is on a distinguished road
Default Shell menu script to adduser

hi everyone

i'm new to linux and needing a bit of help with a script
this script is to create a option menu of, adduser, show the date and quit.
i'm struggling getting the adduser to work, could someone please help me with the following script?
thank you

#!/bin/bash
ps3='Select Option and Press Enter:'
select i in Adduser Date Quit
do
case $i in
Adduser) $username;;
Date) date;;
Quit) break;;
esac
done
Reply With Quote
  #2 (permalink)  
Old 05-05-2009, 01:23 AM
nixcraft's Avatar
Never say die
User
 
Join Date: Jan 2005
Location: BIOS
OS: RHEL
Scripting language: Bash and Python
Posts: 2,710
Thanks: 11
Thanked 245 Times in 184 Posts
Rep Power: 10
nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute
Default

Try something as follows
Code:
#!/bin/bash
while [ 1 ]
do
    clear
    echo "1. Add user"
    echo "2. Date and time"
    echo "3. Exit"
    read -p "Enter your choice [ 1 - 3 ] ?" ch
    case $ch in 
        1)
            read -p "Enter user name : " userName
            useradd  -m $userName
            passwd $userName;;
        2)
            echo "Today is $(date)"
            read -p "Press [Enter] to continue..." readDamKey;;
        3)
            exit 0;;
        *)    read -p "Wrong selection!!! Press [Enter] to continue..." readDamKey;;
    esac  
done
__________________
Vivek Gite
Linux Evangelist
Be proud RHEL user, and let the world know about your enterprise choices! Join RedHat user group.
Always use CODE tags for posting system output and commands!
Do you run a Linux? Let's face it, you need help
Reply With Quote
  #3 (permalink)  
Old 05-05-2009, 06:53 PM
Junior Member
User
 
Join Date: May 2009
OS: pclinux, Ubuntu
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Power: 0
newgeek is on a distinguished road
Default

Hi

thanks a lot for this. really is appreciated!
with more practice i'm hoping i can be the one to give advice.

there is another script you could help me with.
i'm wanting to add users to the system from a list, and i've also tried adding a password to each user, the password is the username plus 123 on the end.
am i on the right tracks?

#!/bin/bash
for i in `names.lst` #text file with names in
do
echo $i
adduser $i
echo $i2123 |password -stdin "$i" #adds password automatically to each username
echo; echo "$Username's and Passwords Updated!"
done

thanks again!

Reply With Quote
  #4 (permalink)  
Old 05-05-2009, 07:21 PM
nixcraft's Avatar
Never say die
User
 
Join Date: Jan 2005
Location: BIOS
OS: RHEL
Scripting language: Bash and Python
Posts: 2,710
Thanks: 11
Thanked 245 Times in 184 Posts
Rep Power: 10
nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute
Default

Check out:

perl or shell script to change the password
__________________
Vivek Gite
Linux Evangelist
Be proud RHEL user, and let the world know about your enterprise choices! Join RedHat user group.
Always use CODE tags for posting system output and commands!
Do you run a Linux? Let's face it, you need help

Last edited by nixcraft; 05-05-2009 at 07:22 PM. Reason: Thread updated as Solved
Reply With Quote
Reply

Tags
adduser , bash , linux , read , shell scripting , unix , useradd


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 
Thread Tools
Display Modes

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 Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads

Thread Thread Starter Forum Replies Last Post
Linux Menu Driven Network Information Program gsb1bee Networking, Firewalls and Security 4 04-06-2009 02:15 PM
FTP SHELL Script gsb1bee Shell scripting 3 24-04-2009 05:32 PM
Not a question: KDE Menu nix CRAFT ROX KDE 0 15-12-2008 02:46 AM
Binary Conversion Of Shell Script (shell script compiler) chandanperl Shell scripting 3 29-07-2008 10:22 AM
writing a shell script to find out my shell name jaymob123 Shell scripting 1 08-10-2007 12:36 AM


All times are GMT +5.5. The time now is 01:32 PM.


Powered by vBulletin® Version 3.8.5 - Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.3.2
©2005-2010 nixCraft. All rights reserved

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