Fortran Library Reference

ttynam, isatty: Get Name of a Terminal Port

ttynam and isatty handle terminal port names.

ttynam: Get Name of a Terminal Port

The function ttynam returns a blank padded path name of the terminal device associated with logical unit lunit.

The function is called by:

CHARACTER ttynam*24

name = ttynam( lunit )

lunit

INTEGER*4

Input 

Logical unit 

Return value 

character*n

Output 

If nonblank returned: name=path name of device on lunit. Size n must be large enough for the longest path name.

If empty string (all blanks) returned: lunit is not associated with a terminal device in the directory, /dev

isatty: Is this Unit a Terminal?

The function

terminal = isatty( lunit )

lunit

INTEGER*4

Input 

Logical unit  

Return value 

LOGICAL*4

Output 

terminal=true: It is a terminal device

terminal=false: It is not a terminal device

is called by:

Example: Determine if lunit is a tty:


    character*12 name, ttynam
    INTEGER*4 lunit /5/
    logical*4 isatty, terminal
    terminal = isatty( lunit )
    name = ttynam( lunit )
    write(*,*) 'terminal = ', terminal, ', name = "', name, '"'
    end

The output is:


 terminal = T, name = "/dev/ttyp1  "