ITEM: CL1420L
Sending console output to multiple devices
ENV:
AIX 3.2.5
7012-360
DESC:
I want to take the console messages and send them to multiple
devices (terminals, telnet session pts's, etc.)
ACT:
The console can only be one "file" such as /dev/tty0 or /tmp/junk.
There are a few things that you could do to get the console
output going to several places:
1) swcons /tmp/consolefile
Then go to any (and as many) sessions as you want and do:
tail -f /tmp/consolefile
or
tail -f /tmp/consolefile &
This way console messages go to a file and also the screen of
each session running the tail on that file.
2) Make the console a named pipe with swcons and run a daemon that
reads from the named pipe and writes its output to whatever
locations desired. Attached below is a C program I wrote to do
just that:
/*
IBM Corp.
3/6/96
tpiped
The code below is provided as-is with no guarantee of any kind.
The purpose of this program is to read from a named pipe and then
send the data read from that named pipe to an arbitrary number of
places. Some example uses would be to send a print job to one
queue and then have it print on several printers - ie get your jobs
in triplicate. You could also send a copy to the console, or to a
tape drive for archival, etc.
The first step is to create a named pipe, for example /dev/mypipe
mknod /dev/mypipe p
With tpiped running in the background, anything that is read from
the named pipe is sent to the destinations. For example:
tpiped /dev/mypipe /dev/lp0 /dev/lp1 /dev/console /dev/rmt0.1 &
Now anything that is sent to /dev/mypipe will be sent to /dev/lp0,
/dev/lp1, /dev/console, and /dev/rmt0.1
To have the print queueing system send jobs to this pipe, just create
a queue that prints to the file /dev/mypipe.
*/
\#include \
\#define MAXDEST 16 /* Max number of places piped output can be sent */
\#define BUFSIZE 256 /* Max chunk read from the pipe in a single read */
int main(int argc, char **argv)
{ FILE *pipe; /* The named pipe we read from */
FILE *dest[MAXDEST + 2]; /* The destinations we write to */
char buffer[BUFSIZE]; /* The buffer we read into */
int i;
/* There must be at least 3 arguments - the command name, the name
of the input pipe, and at least one destination. Of course it
is silly to use this program without at least 2 destinations.
*/
if (argc \< 3)
{
fprintf(stderr, "Usage: %s sourcepipe dest1 [dest2 ... destn]\\n",
argv[0]);
exit(1);
}
/* Open the pipe for reading */
pipe = fopen(argv[1], "r");
/* Open each destination for output */
for(i = 2; i \< argc; i++)
dest[i] = fopen(argv[i], "a");
/* Now infinitely read from the pipe and send to the destinations */
while(1)
if (fgets(buffer, sizeof(buffer), pipe) != NULL)
for (i = 2; i \< argc; i++)
{
fputs(buffer, dest[i]);
fflush(dest[i]);
}
}
NEXT:
Faxing above to you at 804-354-7839
Response:
Closing with Customer Approval
Support Line: Sending console output to multiple devices ITEM: CL1420L
Dated: January 1997 Category: N/A
This HTML file was generated 99/06/24~13:30:17
Comments or suggestions?
Contact us