Summary: Redirect console message

From: Khantipol Kasamsant (sunoct!ktp@Singapore.Sun.COM)
Date: Mon Feb 08 1993 - 01:24:29 CST

My original question was:
      I have a SPARCstation IPC that run some graphic programs. For this
   I want to use it full screen but I also want to see any messages from
   And I have a terminal next to this IPC.
       Is there a way to redirect message from console to this terminal?
What you want to do is edit file /etc/syslog.conf. Change the lines that
direct messages to /dev/console to the device you want.

And many answers recommended Contool. This is very good program that I
use as console. It does very nice filtering console message.

There's also many small C-program that do the job as follow:

Hi Khantipol,
I send you a small c-programm that I am using to divert the console
from my server ( which is on ttya) to a window on my workstation
This is also only a temporary diverting of the console.
Greeting. Ciao Ray

/* program handed out by Dick St.Peters, GE Corporate R&D, Schenectady, NY */

/* modified from Bob Darrow's code */

#include <stdio.h>
#include <sys/types.h>
#include <sys/ioctl.h>
#include <sys/file.h>
main(argc, argv)
    int argc ;
    char **argv ;
    int foo, des ;
    char *tty = "/dev/tty" ;

    if (argc > 1)
      tty = argv[1] ;

    if((des = open(tty, O_RDONLY)) == -1)
        perror("open") ;
        exit(0) ;

    if(ioctl(des, TIOCCONS, &foo) == -1)
        perror("TIOCCONS ioctl") ;
here is a C programme that redirects console messages to ttya

I hope this helps

#include <stdio.h>
#include <fcntl.h>
#include <sys/ioctl.h>

int fd;
        if (fd=open("/dev/ttya",O_RDWR)<0){
                fprintf(stderr,"unable to open ttya\n");
        if (ioctl(fd, TIOCCONS, NULL) == -1) {
                      fprintf(stderr, "could not attach %s to /dev/console\n", "/dev/ttya");
This might work...

Log in on the terminal and compile and run the following program...

main() {
    if ((ioctl(0, TIOCCONS, 0)) == -1)
        fprintf(stderr, "TIOCCONS failed\n");

        - Matt Goheen

Put it in getconsole.c and compile.
Run getconsole on your terminal.

#include <sys/ioctl.h>
if(ioctl(0,TIOCCONS)) printf("BAD ioctl()\n");

Leon Koll

Many thanks to:

Pauline van Winsen (ups!pauline@fourx.Aus.Sun.COM)
Kevin Sheehan (kevin%ups.uucp@fourx.Aus.Sun.COM)
Pete Phillips (
Raymond Ballisti (
Anthony Worrall (
Mark S. Anderson (
Matt Goheen (
Thomas J Davis (
Ralph Finch (
Leon Koll (

 Khantipol Kasemsant                              sunoct!ktp@Singapore.Sun.COM
 Open Computing Technologies
 B.B.Building Suite#1802                              Voice: (662) 260-7590 - 4
 Asoke Rd., Bangkok 10110, THAILAND                    Fax: (662) 260-7595

This archive was generated by hypermail 2.1.2 : Fri Sep 28 2001 - 23:07:27 CDT