in reply to Detecting the current terminal

If you're looking for OS interaction POSIX is (usually, most of the time :) your friend . . .

$ perl -MPOSIX=ttyname -le 'print "I am on tty ", ttyname(STDIN);' I am on tty /dev/pts/34 $ tty /dev/pts/34

The cake is a lie.
The cake is a lie.
The cake is a lie.