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)
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)
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)
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)
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)
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)
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)
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)
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)
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
LEARN ABOUT MINIX
getgrent
GETGRENT(3) Library Functions Manual GETGRENT(3)NAME
getgrent, getgrnam, getgrgid, setgrent, endgrent, setgrfile - group file routines
SYNOPSIS
#include <grp.h>
struct group *getgrent(void)
struct group *getgrnam(const char *name)
struct group *getgrgid(gid_t gid)
int setgrent(void)
void endgrent(void)
void setgrfile(const char *file)
DESCRIPTION
These functions are used to obtain information from the group file. They return this information in a struct group as defined by <grp.h>:
struct group {
char *gr_name; /* login name */
char *gr_passwd; /* encrypted password */
gid_t gr_gid; /* numeric group id */
char **gr_mem; /* null-terminated list of group members */
};
Getgrent() reads the group file entry by entry. Getgrnam() scans the entire group file for the group with the given name. Getgrgid()
looks for the first group with the given gid. The setgrent() and endgrent() functions are used to open and later close the group file.
With setgrfile() one can specify the file to read other than the normal group file. This only sets the name, the next setgrent() call will
open the file. Do not touch the file name while it is active. Use setgrfile(NULL) to revert back to the normal group file.
The usual way to scan the group file is (error checking omitted):
setgrent();
while ((gr = getgrent()) != NULL)
if (appropriate_test(gr)) break;
endgrent();
The gr variable contains the entry that is wanted if non-NULL. The getgrnam() and getgrgid() functions are implemented as in this example,
with error checking of course.
Getgrent() calls setgrent() if this has not yet been done. Setgrent() first calls endgrent() if the group file is still open. (Other
implementations may simply rewind the file.)
FILES
/etc/group The group file database.
SEE ALSO getgroups(2), initgroups(3), getpwent(3), passwd(5).
DIAGNOSTICS
Setgrent() has the same return value and error codes as the open(2) call it uses to open the group file. The getxxx() functions return
NULL on end of file, entry not found, or error. You can set errno to zero before the call and check it after.
NOTES
All getxxx() routines return a pointer to static storage that is overwritten in each call.
Only getgrnam() and getgrgid() are defined by POSIX. The _MINIX_SOURCE macro must be defined before including <grp.h> to make the other
functions visible. The gr_passwd field is also not defined by POSIX, but is always visible. Portable code cannot reliably detect errors
by setting errno to zero. Under Minix it is better to make a getgrent() scan if you need to look up several group-id's or names, but por-
table code had better use several getgrgid() or getgrnam() calls. The getgrent() is usually available on other systems, but may be very
expensive. See initgroups(3) if you are after supplementary group id's.
AUTHOR
Kees J. Bot (kjb@cs.vu.nl)
GETGRENT(3)