if (-t STDIN) { # go on with normal operations } else { # complain and/or re-open to the tty }