Unix Technical Forum

Sam

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 ...


Go Back   Unix Technical Forum > Unix Operating Systems > HP-UX Operating System

Register FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 01-17-2008, 05:37 AM
thesoulcrusher
 
Posts: n/a
Default Sam

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!

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 01-17-2008, 05:38 AM
Kevin Collins
 
Posts: n/a
Default Re: Sam

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
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 06:18 AM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0
www.UnixAdminTalk.com