VT info in bash/C?

Need help with C, C++, perl, python, etc?

VT info in bash/C?

Postby utrrrongeeb » 2006-11-04 11:05

How do you find out which VT is currently visible, and which user is logged on there, in either bash or C/C++? It would be running from an init script. All help is appreciated!
utrrrongeeb formerly lecaro
Art #429775 on 'Etch' 4.0r0
User avatar
utrrrongeeb
 
Posts: 255
Joined: 2006-05-14 09:48
Location: Eastern Canada

Postby ajdlinux » 2006-11-04 20:07

Code: Select all
ps x|grep $$|cut -f2 -d " "


I don't know if there is a better way, but this seems to work to determine the current user if you are running under their shell. But since you won't be using a login shell you would need a different parameter to grep.
Jabber: xmpp:ajdlinux@jabber.org.au
Spammers, email this: ajdspambucket@exemail.com.au
ajdlinux
 
Posts: 2480
Joined: 2006-04-23 09:37
Location: Port Macquarie, NSW, Australia

Postby utrrrongeeb » 2006-11-05 21:55

Thanks for the info; What I'm looking for is the username of whoever is currently logged on to the VT currently visible, either a tty or X. I might be misunderstanding what your script is supposed to do, but I need the the username of whoever is logged on to the currently focused VT available from a script invoked form an init script.
utrrrongeeb formerly lecaro
Art #429775 on 'Etch' 4.0r0
User avatar
utrrrongeeb
 
Posts: 255
Joined: 2006-05-14 09:48
Location: Eastern Canada

Postby ajdlinux » 2006-11-06 20:24

Hmm, there doesn't seem to be an easy way to do it. What exactly is this script for?
Jabber: xmpp:ajdlinux@jabber.org.au
Spammers, email this: ajdspambucket@exemail.com.au
ajdlinux
 
Posts: 2480
Joined: 2006-04-23 09:37
Location: Port Macquarie, NSW, Australia

Postby utrrrongeeb » 2006-11-07 11:08

It's for timing how much each user is logged on in the foreground (so how long each user is actually using it), although that sounds like something that would come with any *nix system. Someone on #debian at Freenode mentioned you run fgconsole to get the VT number. It works. Thanks for the info!
utrrrongeeb formerly lecaro
Art #429775 on 'Etch' 4.0r0
User avatar
utrrrongeeb
 
Posts: 255
Joined: 2006-05-14 09:48
Location: Eastern Canada


Return to Programming

Who is online

Users browsing this forum: No registered users and 4 guests

fashionable