How do you get the device path for the current TTY?
Python has sys.stdin
, sys.stdout
and os.ttyname
but you cannot pass either of the formers to the latter because it requires a file descriptor.
You can pass sys.stdout.fileno
to os.ttyname
:
In [3]: os.ttyname(sys.stdout.fileno())
Out[3]: '/dev/pts/24'
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With