This is a discussion on Sam within the HP-UX Operating System forums, part of the Unix Operating Systems category; --> Hey all, I have a little issue im trying to work out... In SAM, if you goto accounts for ...
| |||||||
| Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| ||||
| Hey all, I have a little issue im trying to work out... In SAM, if you goto accounts for users and groups > users , then goto file, and print to a text file.. Is there a way you can do this on the command line by using grep, sed, awk, etc to grab the same information in the same format, from the passwd file? I am required to print this info to a text file every day, and if i could do it thru cron, itd make my job much easier :-) thanks! |
| ||||
| In article <1158807535.258913.316550@h48g2000cwc.googlegroups .com>, thesoulcrusher wrote: > Hey all, > > I have a little issue im trying to work out... > > In SAM, if you goto accounts for users and groups > users , then goto > file, and print to a text file.. > > Is there a way you can do this on the command line by using grep, sed, > awk, etc to grab the same information in the same format, from the > passwd file? > > I am required to print this info to a text file every day, and if i > could do it thru cron, itd make my job much easier :-) How about this: #!/usr/bin/ksh cat <<EOF Login User ID Primary Office Office Name (UID) Real Name Group Phone Location EOF OldIFS="$IFS" while read line do IFS=":" set -o noglob set -- $line user=$1 uid=$3 gid=$4 gecos=$5 if [[ ! -z "$gid" ]] then set -- $(grget -g $gid) group=$1 fi IFS="," set -- $gecos name=$1 office=$2 phone=$3 IFS="$OldIFS" printf "%-8s %-8d %-39s %-8s %-10s %s\n" "$user" "$uid" "$name" "$group" "$phone" "$office" done </etc/passwd IFS="$OldIFS" It should be pretty close... Kevin -- Unix Guy Consulting, LLC Unix and Linux Automation, Shell, Perl and CGI scripting http://www.unix-guy.com |
| Thread Tools | |
| Display Modes | |
|
|