Thx for all the help so far, I really appreciate it, this is the last task I have to do then I am no longer a trainee ^^, which means I can use whatever utility I want.
I need to write a script that does more or less what is shown below.
The Users Name
PID TTY TIME CMD
12345 pts/3 00:00:00 vim
The Users2 Name2
PID TTY TIME CMD
12345 pts/2 00:00:00 vim
Print out all users currently logged on to the system and display the processes they are running.
The problem I am facing is I don�t know how to acquire the users name (the actual name not the Username), as for the format it has to be like shown above more or less.
And again I cant use SED or Awk (I will be free to use them after am done with this :)).
So its gona be one of those while read line statements.
So the 1 million dollar question is how I format it by field
Will the cut command help me at all here?
I am starting to think this guy uses Google to find the tasks that he wants me to do, This is unbelievably similar to what i want to do , maybe it is just an exercise that is given to most beginners or something.
I have a question though, this programme will be ran by a few people, if one of those people where to change a process name or amend a users name, will this outcome be effected?
you'll need write a 'generic' script and pass the user ID to the script as a parameter. The process name(s) will be listed by whatever tool you use all the processes.
The snippet of the code provided above deals only with the userID->userName mapping - not with the listing of processes.
'junk' is just a placeholder for fields in the '/etc/passwd' file we/you want to skip reading.
Make sure you copy/paste the code 'as-is' - you seem to be refering to 'useID' and not 'userID' as it's used in the code snippet.
copy/paste the line from the /etc/passwd file with 'uucp' on it, pls.
You understand that this was just a 'hint' how to do the mapping, doncha ya? You can assign any existing userID from your system to the 'userID' variable. Probably copy/pasting a couple of lines here help.....
Sorry if I caused confusion on what I am trying to achieve
1) I need to find out users currently logged on to the system.
2) I need to find out what processes they are running.
3) I need to print those processes on the screen, for each user along with their actual name.
I am assuming the only way to get the name at this point if from the �/etc/passwd� file
Can this be done without using SED or AWK?