Running Scripts from cron but with controlling terminal (AIX)

Some Programs, like passwd(1) or, as in our (wu-wien.ac.at) case, kas, the kerberos authentication system, require that they are run from a controlling terminal. They try to open /dev/tty for writing and will refuse to work if this is impossible.

The solution is quit simple: acquire a controlling terminal beforehand using openpty(3) or forkpty(3). On AIX the semantics is a little bit different, it uses /dev/ptc as a svr4 - style "cloning" device.

In Stevens book "Advanced Programming in the UNIX Environment" there is an example Program in Chapter 19, "Pseudo Terminals". This program does not work on AIX, because

-) it uses the SVR4 /dev/ptmx instead of /dev/ptc (AIX).

-) it tries to push "ptem" "ldterm" "ttcompat" STREAMS modules onto the tty stream in the slave program. This does not seem to be necessary/possible anymore. I commented these lines out.

HOWTO do it