python and vc numbers

Daniel Dalton d.dalton at iinet.net.au
Mon Nov 30 06:05:18 EST 2009


On Mon, Nov 30, 2009 at 02:26:14AM -0800, Chris Rebert wrote:
> Also, in my quickie newbie experimentation with `screen`, each screen
> "window" seems to get a unique tty#. Admittedly I am running OS X

Correct
(Which creates the problem)

> Perhaps if you could explain your problem in greater detail?

Sure, well, first I am running screen in a console. Under screen I open
many windows, but in my .screenrc file, after 15 minutes screen runs 
screen lock
which is the equivalent of /usr/local/bin/lock 
/usr/local/bin/lock is my python script, basically it checks to see if
file /tmp/.vlock.run exists and if it does, will not run vlock again,
but if it doesn't then passes onto vlock. When vlock returns a clean
exit, eg. the user unlocks the term, my program removes that statefile
and exits nicely. (the purpose of this is so screen doesn't lock the
system hundreds of times, asking for a password hundreds of times, or
when using -na it doesn't create a bunch of useless blank "lock" windows
in my screen session.
This works well, but it is only useful for one tty,
because if you lock tty1 then it blocks tty2 etc. I know I could have a
bunch of different scripts using different files, but this just gets to
complicated to manage, so the logical solution is to append vc number to
the filename:
/tmp/.vlock.run.1 
/tmp/.vlock.run.2 
etc
So we can identify which consoles have been locked, and which
haven't. The problem lies with the fact, I can't find a reliable way to
determine the current console number with python or any bash tool. When
I say console number, I mean the actual console number, not screen
window or device it is sending to or whatever.

I am totally blind, and therefore use a package called brltty, and this
package has the ability to show me what number console I'm in, and even
under screen always works reliably and consistently. So anyone know of a
better solution, now I have described the issue in great detail?

Thanks very much for all the help.

Cheers,
Dan
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 198 bytes
Desc: Digital signature
URL: <http://mail.python.org/pipermail/python-list/attachments/20091130/98135e79/attachment-0001.sig>


More information about the Python-list mailing list