TTYNAM (The GNU Fortran Compiler)

### 8.290 `TTYNAM` — Get the name of a terminal device ¶

Synopsis:

  `CALL TTYNAM(UNIT, NAME)`
  `NAME = TTYNAM(UNIT)`

Description:

  Get the name of a terminal device. For more information, see `ttyname(3)`.

  This intrinsic is provided in both subroutine and function forms; however, only one form can be used in any given program unit.

Class:

  Subroutine, function

Arguments:

  UNIT | Shall be a scalar `INTEGER`.
  NAME | Shall be of type `CHARACTER`.

Example:

      PROGRAM test_ttynam
        INTEGER :: unit
        DO unit = 1, 10
          IF (isatty(unit=unit)) write(*,*) ttynam(unit)
        END DO
      END PROGRAM

Standard:

  GNU extension

See also:

  `ISATTY` — Whether a unit is a terminal device