|
Home > Archive > Unix Programming > January 2004 > looking for a specific user who is "logged on"
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
looking for a specific user who is "logged on"
|
|
| whgill 2004-01-23, 5:12 pm |
| morning all,
Working on a C program, and I need to be able to run find out if a
user (a specified username) is currently logged into the system and
running the ksh. Ideally, I would like to be able to find all
processes that the user is currently running. I'm sure there is some
system call out there that will return that information to me, or at
least some method to run the system process tree and find it, but I've
not a clue what call or method to use, and going through each call in
the C library is getting a bit tiresome Can someone with the
proper clues please point me in the right direction? This isn't a
Korn shell, it's a C program. Operating System is Solaris 8.
Thanks for the hints, and have a great day!
| |
| Tobias Oed 2004-01-23, 5:12 pm |
| whgill wrote:
quote:
> morning all,
>
> Working on a C program, and I need to be able to run find out if a
> user (a specified username) is currently logged into the system and
> running the ksh. Ideally, I would like to be able to find all
> processes that the user is currently running. I'm sure there is some
> system call out there that will return that information to me, or at
> least some method to run the system process tree and find it, but I've
> not a clue what call or method to use, and going through each call in
> the C library is getting a bit tiresome Can someone with the
> proper clues please point me in the right direction? This isn't a
> Korn shell, it's a C program. Operating System is Solaris 8.
>
> Thanks for the hints, and have a great day!
What about a simple popen("ps","r"); The probelm is that ps's output is
fairly system dependent.
Tobias.
| |
| Tobias Oed 2004-01-23, 5:12 pm |
| whgill wrote:
quote:
> morning all,
>
> Working on a C program, and I need to be able to run find out if a
> user (a specified username) is currently logged into the system and
> running the ksh. Ideally, I would like to be able to find all
> processes that the user is currently running. I'm sure there is some
> system call out there that will return that information to me, or at
> least some method to run the system process tree and find it, but I've
> not a clue what call or method to use, and going through each call in
> the C library is getting a bit tiresome Can someone with the
> proper clues please point me in the right direction? This isn't a
> Korn shell, it's a C program. Operating System is Solaris 8.
>
> Thanks for the hints, and have a great day!
What about a simple popen("ps","r"); The probelm is that ps's output is
fairly system dependent.
Tobias.
| |
| Joseph Dionne 2004-01-23, 5:12 pm |
| Tobias Oed wrote:quote:
> whgill wrote:
>
>
>
>
> What about a simple popen("ps","r"); The probelm is that ps's output is
> fairly system dependent.
> Tobias.
>
or use who
| |
| Joseph Dionne 2004-01-23, 5:12 pm |
| Tobias Oed wrote:quote:
> whgill wrote:
>
>
>
>
> What about a simple popen("ps","r"); The probelm is that ps's output is
> fairly system dependent.
> Tobias.
>
or use who
| |
| Samuel Walters 2004-01-23, 5:12 pm |
| I don't know of a portable c call to handle what you ask for. This
doesn't mean that one doesn't exist, it just means I don't know if it
exists.
|Thus Spake Joseph Dionne On the now historical date of Fri, 09 Jan 2004
16:10:20 +0000|
quote:
> or use who
w is more verbose, and includes what program is currently being run by
users. It does, however, hide a great deal of what's going on. For
instance, in the following examples, I've got a web browser, aterm running
screen and PAN. None of this shows up.
ps provides a fairly non-portable solution, but combined with grep, it
might give you all the information you need, which in the end is just
existance/non-existance of user.
[0:0]-[ swalters@musashi:~/projects/gnntpd ] who
swalters vc/1 Jan 9 14:01
swalters pts/1 Jan 9 14:02 (:0:S.0)
[0:0]-[ swalters@musashi:~/projects/gnntpd ] w
18:06:01 up 4:06, 2 users, load average: 0.65, 0.34, 0.22
USER TTY LOGIN@ IDLE JCPU PCPU WHAT
swalters vc/1 14:01 4:04m 0.03s 0.00s /bin/sh /usr/X11R6/bin/startx
swalters pts/1 14:02 0.00s 0.02s 0.00s w
[0:0]-[ swalters@musashi:~/projects/gnntpd ] ps U swalters | grep [b]ash
1892 vc/1 S 0:00 -bash
2018 pts/0 S 0:00 bash
2024 pts/1 S 0:00 -/bin/bash
Sam Walters
--
Never forget the halloween documents.
http://www.opensource.org/halloween/
""" Where will Microsoft try to drag you today?
Do you really want to go there?"""
| |
| Samuel Walters 2004-01-23, 5:12 pm |
| I don't know of a portable c call to handle what you ask for. This
doesn't mean that one doesn't exist, it just means I don't know if it
exists.
|Thus Spake Joseph Dionne On the now historical date of Fri, 09 Jan 2004
16:10:20 +0000|
quote:
> or use who
w is more verbose, and includes what program is currently being run by
users. It does, however, hide a great deal of what's going on. For
instance, in the following examples, I've got a web browser, aterm running
screen and PAN. None of this shows up.
ps provides a fairly non-portable solution, but combined with grep, it
might give you all the information you need, which in the end is just
existance/non-existance of user.
[0:0]-[ swalters@musashi:~/projects/gnntpd ] who
swalters vc/1 Jan 9 14:01
swalters pts/1 Jan 9 14:02 (:0:S.0)
[0:0]-[ swalters@musashi:~/projects/gnntpd ] w
18:06:01 up 4:06, 2 users, load average: 0.65, 0.34, 0.22
USER TTY LOGIN@ IDLE JCPU PCPU WHAT
swalters vc/1 14:01 4:04m 0.03s 0.00s /bin/sh /usr/X11R6/bin/startx
swalters pts/1 14:02 0.00s 0.02s 0.00s w
[0:0]-[ swalters@musashi:~/projects/gnntpd ] ps U swalters | grep [b]ash
1892 vc/1 S 0:00 -bash
2018 pts/0 S 0:00 bash
2024 pts/1 S 0:00 -/bin/bash
Sam Walters
--
Never forget the halloween documents.
http://www.opensource.org/halloween/
""" Where will Microsoft try to drag you today?
Do you really want to go there?"""
|
|
|
|
|