Sam - HP UX

This is a discussion on Sam - HP UX ; 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 ...

+ Reply to Thread
Results 1 to 2 of 2

Thread: Sam

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


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

+ Reply to Thread