Open In App

Python | os.ctermid() method

Improve
Improve
Like Article
Like
Save
Share
Report

OS module in Python provides functions for interacting with the operating system. OS comes under Python’s standard utility modules. This module provides a portable way of using operating system dependent functionality.

os.ctermid() method in Python is used to get the filename corresponding to the controlling terminal of the process.

Syntax: os.ctermid()

Parameter: Not required

Return Type: This method returns a string value denoting the filename corresponding to the controlling terminal of the process.

Code : Use of os.ctermid() method




# Python program to explain os.ctermid() method 
  
# importing os module 
import os
  
# Get the filename corresponding 
# to the controlling terminal
# of the process.
filename = os.ctermid()
  
  
# Print the filename corresponding 
# to the controlling terminal
# of the process.
print(filename)


Output:

/dev/tty

Last Updated : 22 May, 2019
Like Article
Save Article
Previous
Next
Share your thoughts in the comments
Similar Reads