SilverHood
FH is my second home
- Joined
- Dec 23, 2003
- Messages
- 2,284
what I need is output to the screen in the following format
NAME
PID TTY TIME CMD
I'm using the ps -U command to print the above. What I'm strugling with is the syntax for nesting the ps command within my w - method.
This is what I have at the moment:
I can get it to work as a pure command line, but not in my script. I'm totally stumped. Any ideas?
NAME
PID TTY TIME CMD
I'm using the ps -U command to print the above. What I'm strugling with is the syntax for nesting the ps command within my w - method.
This is what I have at the moment:
Code:
#!/bin/bash
w | cut -d ' ' -f1 | sort -u | while read userID
do
while IFS=: read userIDpasswd junk junk junk userName junk
do
if [ "${userID}" = "${userIDpasswd}" ]; then
echo "userID->[${userID}] userName->[${userName}]"
ps -U [${userName}]
fi;
done < /etc/passwd
done
I can get it to work as a pure command line, but not in my script. I'm totally stumped. Any ideas?