Sponsored Content
Operating Systems BSD Creating an array out of users: shell script Post 302501974 by Scott on Sunday 6th of March 2011 06:07:01 AM
Old 03-06-2011
One option:

Code:
USERS=("" $(awk -F: '{print $1}' /etc/passwd))

echo ${USERS[@]} | awk '{print ++C ") " $1}' RS=" "

printf "Enter a number:  "
read OPTION

echo You chose ${USERS[$OPTION]}

Or you could use select, for example:
Code:
USERS=("" $(awk -F: '{print $1}' /etc/passwd))

PS3="Select a user: "
select USER in ${USERS[@]}; do
 break
done

echo You chose $USER

(you need to modify the awk to remove blank lines, comments and system users)
 

10 More Discussions You Might Find Interesting

1. Programming

Creating an array to hold posix thread ids: Only dynamic array works

I am facing a strange error while creating posix threads: Given below are two snippets of code, the first one works whereas the second one gives a garbage value in the output. Snippet 1 This works: -------------- int *threadids; threadids = (int *) malloc (num_threads * sizeof(int)); ... (4 Replies)
Discussion started by: kmehta
4 Replies

2. Shell Programming and Scripting

Help with shell script - creating users

echo -e "Enter in a username : \c" read username grep "^$username:" /etc/passwdWhat I'm trying to do is take in a username from my script and I need to be able to check if that username already exists. If it does the script should display a message saying that the user already exists and exit. ... (2 Replies)
Discussion started by: shadowcat
2 Replies

3. Shell Programming and Scripting

Script in bash wchich creating a new users...

Hi, I am a new on this forum but i like :) I need a script in bash which will be crating a new user with folder for websites. For example: I will run this program and he creating a new user(with my name) and folder whcich name like user and if i will localho/~user in browser, she show me files from... (1 Reply)
Discussion started by: puclavv
1 Replies

4. UNIX for Dummies Questions & Answers

Script for creating users

Hi, I wants to create the users for multiple machine from single main server using the shell script ,can you please help me on this.... (2 Replies)
Discussion started by: Rahulne25
2 Replies

5. Shell Programming and Scripting

Writing a script on creating and comparing users

Hello Everybody i am a newbie to the bash scripting.please can someone help me out here.i want to write a script on creating 10 users with passwords and comparing the users to the ones in /etc/passwd file.am i gonna use arrays in creating the 10 users or what?and again, how do i compare both... (1 Reply)
Discussion started by: bruno_brunt
1 Replies

6. Shell Programming and Scripting

Creating new users using a text file as imput (using only shell script and/or awk)

I need somebody who could help with an exercise. You have a text file called users.txt with this info inside: users.txt: user1:1234:/home/homedir1 ; user2:1234:/home/homedir2 ; user3:1234:/home/homedir3 ; user4:1234:/home/homedir4 ; The script should create an user using the... (2 Replies)
Discussion started by: marcosruiz
2 Replies

7. Red Hat

Script for Creating more users like 50 in one server

Hi friends could you please share me the script to create more users in one server except newusers, is there any option to change secondary group and how to print passwd and changing the age all these things how can i edit in newsers.. please help me (0 Replies)
Discussion started by: indiankrish
0 Replies

8. Shell Programming and Scripting

Shell script for creating multiple users with password

for UserName in `cat users` ; do useradd -d /u02 -s /usr/libexec/openssh/sftp-server -G ftp-users $UserName ; PassWord=$( echo $( tr '' '' <<< ${UserName:0:1} )${UserName:1} ) ; echo "$PassWord@123" | passwd $UserName --stdin ; done can some one explain what the bold text do Please use... (5 Replies)
Discussion started by: James0806
5 Replies

9. Shell Programming and Scripting

Pass C shell array to another C shell script(csh) and shell(sh)

Dear Friends, Please help me on this my script name is send.csh In this i have written the statement like this set args = ( city state country price ) I want to pass this array to another c shell called receiver.csh. and i want to use it in this c shell or how to pass to... (2 Replies)
Discussion started by: SA_Palani
2 Replies

10. HP-UX

Creating a group of users with script

Hi, I have a file with usernames, and the comment section, e.g : Data removed by request of sanchitadutta91, 20 May 2020 I need to add these users into a server. Is it possible to use a script to create the users, together with the comment ? From the commandline to add one user, the... (2 Replies)
Discussion started by: anaigini45
2 Replies
FVWM-THEMES-MENUAPP(1)						   FVWM Utility 					    FVWM-THEMES-MENUAPP(1)

NAME
fvwm-themes-menuapp - fvwm-themes menus utility SYNOPSIS
fvwm-themes-menuapp --build-menu or --com-mode or--help or --version [ --site] [ --menu-files [file1,file2,...] ] [ --remove-popup] [ --com-name name] DESCRIPTION
This script is not a user script. It is used by Fvwm-Themes to do differrent task concerning menu and other related things. This scripts can do the following: Parse and rebuild FVWM configuration files to build a clean menu from them: application not in the path are removed, certain unuseful sub menus and separator are removed (--build-menus option). It can work in a locked way and communicate (via fvwm-themes-com) with FvwmScript-Menus or any other programs (--com-mode option). See below for the list of query that you can ask to fvwm-themes-menuapp via fvwm-themes-com. Plan for the future: use an application data base and parse and build (Mini)Icon Styles. OPTIONS
You must use (only) one of the following four options: --help - show the help and exit --version - show the version and exit --build-menus - Cause fvwm-themes-menuapp to build clean menus. --com-mode Run fvwm-themes-menuapp under the "communication mode". --menu-files [file1,file2,...] - files which are read and written by fvwm-themes-menuapp. By default, fvwm-themes-menuapp will read $FT_DATADIR/themes/default/menus-programs with the --site option. Without the --site option fvwm-themes-menuapp will read menus-programs and menus-extra (if found) in the fvwm-themes personal dir: $FVWM_USERDIR/themes/personal. If menus-programs is not found in this direc- tory the site's menus-programs file is used (the one under $FT_DATADIR). Moreover, if menus-extra is not found, a virtual such file is cre- ated so that the "personal" menus can be created (MenuFvwmPersonal) in it. --site - Change the default for the --menu-files option. --remove-popup - Remove the sub menu popup that popup empty menu (only useful with --build-menus). In fact only certain sub menu popup are removed. --com-name name - use name as name for communication with fvwm-themes-com. By default, "appmenu" is used, but you should use "app- menu-pid" as name where pid is the pid of the program that want to talk to fvwm-themes-menuapp so that fvwm-themes-menuapp can exit if this program exit and so that fvwm-themes-menuapp can kill the program if an internal error happen in fvwm-themes-menuapp. On the other hand, if you want to talk with fvwm-themes-menuapp in, say, a terminal you must not give an name as "menuapp-an_integer" as name. COMMUNICATION COMMANDS
Start fvwm-themes-menuapp as: fvwm-themes-menuapp --com-mode [--com-name=menuapp-pid ...] Then use fvwm-themes-com as: fvwm-themes-com --name menuapp[-pid] [--lock-and-get] --message="Command" where Command is one of the following. All this commands are "lock and get" but the exit command. A return value of 0 indicate an error. menus-list - List of the menus. root-menus-list - List of the "root" menus. root-menus i - ith root menu. menu-items menu_name - List of the items of the menu menu_name. item menu_name:i - Information on the ith item of the menu menu_name. remove menu_name:i - Remove the ith item of the menu menu_name. move-up menu_name:i - Move up the ith item of the menu menu_name. move-down menu_name:i - Move down the ith item of the menu menu_name. add-or-edit-item X --it='menu_name:i' --t='type' --n='name' --mi='menu-icon' --wd='working dir or window title' where X is either A for add or E for edit, see the code for details :) selection-items - List of the items in the selection. add-item-to-selection menu_name:i - Add the ith item of the menu menu_name to the selection. remove-sel-item i - Remove the ith item of the selection. remove-all-sel-item - Remove all the selection items. copy-sel-item menu_name:i:j - Copy the jth item of the selection after the ith item of the menu menu_name. copy-all-sel menu_name:i - Copy all the selection after the ith item of the menu menu_name. try - Out put the contents of the files (as soon as possible will run the good fvwm-themes-config command). save - wrote back the files exit - Stop fvwm-themes-menuapp. USAGE
When fvwm-themes is installed, fvwm-themes-menuapp is run as: fvwm-themes-menuapp --site --build-menus --remove-popup FvwmScript-Menus used (and in fact is based on) fvwm-themes-menuapp. See this FvwmScript script for examples with the com-mode option. AUTHORS
Olivier Chapuis <olivier.chapuis@free.fr>, 5 May 2000. COPYING
The script is distributed by the same terms as fvwm itself. See GNU General Public License for details. BUGS
Report bugs to fvwm-themes-devel@lists.sourceforge.net. perl v5.8.0 2003-06-05 FVWM-THEMES-MENUAPP(1)
All times are GMT -4. The time now is 11:44 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy