PDA

View Full Version : help with script please!!!!


darylzero
05-27-2004, 05:48 AM
What i need to do is take this information from my unix system (pretend like there is more people logged in):

18:21:53 up 68 days, 4:23, 1 user, load average: 0.26, 0.11, 0.04
USER TTY FROM LOGIN@ IDLE JCPU PCPU WHAT
d1234567 pts/0 student 6:21pm 0.00s 0.06s 0.01s w
[d12345678@puma d12345678]$

and have the output look like this

===========================================================
$ disp_name
1 ) d0035356 User = alex balogun
2 ) d0035318 User = mark cullen
3 ) d9900141 User = andrew kim
4 ) d0064509 User = george petrov
5 ) d0035024 User = hakimah malik
6 ) d0033997 User = richard becker
7 ) d0031284 User = timothy schneider
8 ) d0029651 User = amanda knop
9 ) d0036993 User = david vastola
10 ) d0027750 Multiple users for that user ID
User = stoyan martinov
User = odise prifti
11 ) d0033740 User = muhammadsaadrafi khan
12 ) d0030182 User = learon reid
13 ) d0035818 User = anthony pontone
14 ) d0034645 User = dax patel
15 ) d0039717 User = erik alm
$
=========================================================


This is what I have so far, I just don't know what to do.

let counter=1
echo "-----------------------------------------------------"

for id in $(w -h | awk '{print $1}')
do
name=$(awk -F: '/'^$id:'/ {print $5}' /etc/passwd)
echo "$counter ) $id user=$name"
let counter=counter+1
done

echo "-----------------------------------------------------"

Spookster
05-27-2004, 06:58 AM
A shell script homework assignment. I remember those in college. I had to write a menu system giving menu options to be able to do simple tasks such as that one.

Since this is pretty obviusly a homework assignment we cannot write the code for you but we can guide you in the right direction and answer specific questions. Which shell are you doing this in? Bash it looks like.

I don't have a linux box sitting in front of me so it would be helpful if you told us what if any errors you are getting or show us what the current output is.