I tried the code in three different directories and received perfect results. Good job and thank you! Although I now have to hit the bash guides to fully understand what is happening.
Then later I might throw that routine into /etc/bashrc as a function.
Quote:
I think the tty command is what you need for the one. I think you'll find a correspondence between the inittab label the the tty command output.
|
Sort of. Maybe. I don't know! In non-X the
tty command returns the tty number in the form of
/dev/ttyn. Good enough. In X the same command returns
/dev/pts/n. Additionally, I can get tty to return some interesting results when in X.
I use only three ttys in my inittab. This evening I started X in run-level 4. Despite using only 3 ttys, because of the way I edited the KDM Xservers file, vt7 is the virtual terminal number. So far so good. I toggled to tty3 and started X from there with
startx. The virtual terminal number is vt8. I opened Konsole and typed tty. I received
/dev/pts/0. I toggled to my first X session at vt7/tty1. I opened Konsole and tty returned
/dev/pts/1.
I then toggled to my second X session, vt8, and exited KDE/X. I returned to X session tty1/vt7. I opened Konsole and tty returned
/dev/pts/0.
I then opened a new KDE/X session using the
Start New Session menu option, which gets assigned to vt8. I opened Konsole in that session and tty returned
/dev/pts/0. I toggled to tty3 and again manually started X with startx. I opened Konsole and tty returned
/dev/pts/1. I toggled to my first KDE/X session at vt7 and tty returned
/dev/pts/2.
The preliminary indication is that when in X, the tty command responds in the order of who makes the request. The actual tty or vt is irrelevant. In non-X the tty command works as expected. Is this a bug or a feature? I don't know!
Despite this momentary fun I'm still looking for a way to programmatically determine the virtual terminal (vt) number that X assigns.
Quote:
Recently, I've taken up perl to manage this sort of thing, after years of shell scripts and awking. The code tends to be a little cleaner in perl when you're finished.
|
Possibly one day I will look at perl in earnest. Too much else on my plate right now!