Sponsored Content
Top Forums Shell Programming and Scripting How to get list of user into an array.. Post 302452069 by pludi on Thursday 9th of September 2010 04:46:10 AM
Old 09-09-2010
To emulate cut:
Code:
open my $group, '<', '/etc/group';
my @groups = map { my @a = split /:/; $a[0] . ':' . $a[2] } <$group>;
close $group;

To create a hash mapped on the group name:
Code:
open my $group, '<', '/etc/group';
my %groups = map { my @a = split /:/; $a[0], $a[2] } <$group>;
close $group;

 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

getting data list into a hash array

Begginer alert!! I have just started learning perl and have got stuck. I need to initialize a hash array with values from a list. I've been told to do this using a split command, but its just not happening. Here is the script and output: SCRIPT: #!/bin/perl system("clear"); ... (5 Replies)
Discussion started by: topcat8
5 Replies

2. Shell Programming and Scripting

sh shell user input and stote it to a array

Dear Friends, I am doing a sh shell script , But I dont have any idea how to read value from user Keyboard and store them to an array .. Is it possible or not I am not also sure in sh shell script ? EX:- #! /bin/sh read DATA echo "DATA -" $DATA echo "DATA -" $DATA echo "DATA... (7 Replies)
Discussion started by: user_prady
7 Replies

3. UNIX for Dummies Questions & Answers

How to display values from user input array?

Hi all, I wrote a script that reads inputs from user and store in array named "input". The number of elements in the array is not fixed - determined only after user exit the while loop that reads the array values : x=1 echo "Enter first value" read input while } != "exit" ] do ... (1 Reply)
Discussion started by: luna_soleil
1 Replies

4. Shell Programming and Scripting

storing values in a list or array

i have a file called file.txt having the following entries. 2321 2311 2313 4213 i wnat to store these values in a list and i want to iterate the list using loop and store it in another list (1 Reply)
Discussion started by: KiranKumarKarre
1 Replies

5. Shell Programming and Scripting

Dividing user Array by 2

Hello! Im trying to divid the numbers inputed by <STDIN> by 2. This is what I have: print "The input array divided by 2 is as follows:\n"; foreach ((@userArray)/2) {print} But it is not dividing by 2? Any help is valuable!! Ben (3 Replies)
Discussion started by: bigben1220
3 Replies

6. Shell Programming and Scripting

How to get list of user into an array in perl script

Hi, cut -d: -f1,3 /etc/group >rpt.out I have a doubt in perl. right i am getting list of group user id into rpt.out file. instead i need to store it as an array in perl script. could you please tell me how can i get list of user into an array in perl script.. thanks in advance. (1 Reply)
Discussion started by: solo123
1 Replies

7. Shell Programming and Scripting

Write a scripts to kill idle user for 60 min. & email user list to admin in text file

Folks, I have written one script for following condition by referring some of online post in this forum. Please correct it if I'm missing something in it. (OS: AIX 5.3) List the idle user. (I used whoidle command to list first 15 user and get username, idle time, pid and login time).... (4 Replies)
Discussion started by: sumit30
4 Replies

8. Shell Programming and Scripting

Assign user input to already declared array

What I am doing is creating a top menu, which a user will select a choice with a number entry. That number corresponds to a string in an array. I then want to assign that response to another array I've already declared. For example: #!/bin/bash colors=(red blue yellow) red=(cherry fire)... (2 Replies)
Discussion started by: Akilleez
2 Replies

9. Shell Programming and Scripting

how to prompt the user to enter an array in tcsh

Hello, I am writing a script that requires the user to enter a string of numbers: ex: 134 345 865 903 This command only allows for one variable to be entered: set "var" = $< and than once I got the array I want to change it to a list with each input on a different line: ... (1 Reply)
Discussion started by: smarones
1 Replies

10. Shell Programming and Scripting

Manipulating a list into a two-dimensional array

hi, total newbie to shell scripting and wondering if some of you guru's can give me a hand on a problem I'm trying to solve. The tmplsnr.a file contains LSNR_51526 db1 db2 LSNR_51527 db3 db4 db5 Summary - depending on which db is set, the script will start the relevant listener... (5 Replies)
Discussion started by: mingy10
5 Replies
hpitree(1)							      OpenHPI								hpitree(1)

NAME
hpitree - A openhpi sample application that shows in details the resources (rpt's) and resources' manamegement instruments (rdr's) data structures of the managed openHPI complex. SYNOPSIS
hpitree [-D nn] [-N host[:port]] [-C <cfgfile>] [-acdiorsw ] [-n nn] [-x] [-h] hpitree [--domain=nn] [--host=host[:port]] [--cfgfile=file] [--all] [--controls] [--rdrs] [--inventories] [--rpts] [--sensors] [--watchdogs] [--overview] [--resource=nn] [--debug] [--help] DESCRIPTION
hpitree walks the Resource Presence Table (RPT) of the managed openHPI complex, and displays in details the resources (rpt's) and resources' management instruments (rdr's) data structures. If no domain or host is selected, hpitree uses the default domain as specified in the openhpiclient.conf file. OPTIONS
(No Option) Display all rpts and rdrs Help Options: -h, --help Show help options Application Options: -a, --all Display all rpts and rdrs (default) -r, --rpts Display only rpts -d, --rdrs Display rdr records -o, --overview Display system overview: rpt & rdr headers -s, --sensors Display only sensors -c, --controls Display only controls -w, --watchdogs Display only watchdogs -i, --inventories Display only inventories -n nn, --resource=nn Display only resource nn and its topology -D nn, --domain=nn Select domain id nn -X, --debug Display debug messages -N "host[:port]", --host="host[:port]" Open session to the domain served by the daemon at the specified URL (host:port). This option overrides the OPENHPI_DAEMON_HOST and OPENHPI_DAEMON_PORT environment variables. If host contains ':' (for example IPv6 address) then enclose it in square brackets. For example: "[::1]" or "[::1]:4743". -C "file", --cfgfile="file" Use passed file as client configuration file. This option overrides the OPENHPICLIENT_CONf environment variable. SEE ALSO
hpi_shell hpialarms hpifan hpipower hpithres hpidomain hpigensimdata hpireset hpitop hpiel hpiiinv hpisensor hpiwdt hpievents hpionIBMblade hpisettime hpixml ohdomainlist ohhandler ohparam AUTHORS
Authors of this man page: Peter D Phan (pdphan@users.sourceforge.net) Ulrich Kleber (ulikleber@users.sourceforge.net) Anton Pak (avpak@users.sourceforge.net) 3.2.1 2011-09-20 hpitree(1)
All times are GMT -4. The time now is 10:44 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy