Alright, can someone finish this list?
All OS(defined by implementation):
stdin
stdout
stderr
Windows / Dos
Console = CON
Printer = PRN
UNIX
Console:
Printer:
Apple:
Console:
Printer:
Lynix:
Console:
Printer:
Printable View
Alright, can someone finish this list?
All OS(defined by implementation):
stdin
stdout
stderr
Windows / Dos
Console = CON
Printer = PRN
UNIX
Console:
Printer:
Apple:
Console:
Printer:
Lynix:
Console:
Printer:
Consoles in Unix, uh oh...
My Linux machine has about 330 tty?? entries in the /dev/ directory, all of these are, in theory, consoles. In addition, it has the stdin, stdout and stderr devices, which address the current console. Then there's about 250 pseudo-terminals. And I believe the entries in the vc/ directory are some terminal-like things too.
The only printer connected is referred to alternatively as /dev/lp0 or as /dev/printers/0.
So these would be the stream names? Maybe I am not being clear, or most likely I'm stupid :p , lets say I wanted to open a stream, I would do it like:Quote:
/dev/lp0 or as /dev/printers/0.
Now in windows/DOS if I wanted to open the printer stream, I could use "PRN" for stream name, conversly if I wanted another stream to the monitor I could use "CON" for the streamName.Code:fstream myStream;
myStream.open(streamName, ios_base::open_mode Mode);
Yes, but Unix doesn't have these special built-in names. Unix instead uses special file-like things, the device nodes. These are far more flexible - but as a consequence they're also less predictable.
Ok, so can these device nodes be treated as streams? Or better question how can you print? Or do you have to rely heavily on the OS?
They can be treated like files. And yes, you can print by opening lp0. However, remember that the printer needs a "\r\n" pair to properly start a new line, and Unix iostreams won't do the conversion from the in-program "\n" for you.
Thankyou. So the current list is:
All OS
stdin
stdout
stderr
Evidently there are too many console types in Unix to list? However stdout will give you the console.Code:
Windows/Dos Unix / Lynix Mac
Printer PRN lp0 ?
Console CON ? ?
*edit*
In case I am not being clear I am hoping for someone to help fill in the question marks. ;)
Unless it's been redirected :)
yes, and that is why I am looking for the device node. How would you set stdout back in unix after you redirect it with freopen?
Good question. When you're in an SSH session, you can find out the pseudo-terminal with the SSH_TTY environment variable. But I'm not aware of any other way to find out your current terminal. Yet there must be, because ps displays the information. There's also the tty program, which displays the tty your stdin is linked to. Or "not a tty" if it's redirected.
You might want to look at the source of this little app.
I'm not good in C++ anymore, but unix has standard system calls to identify terminals.
To start with SUS2 compliance dictates that "/dev/tty" can be used to open or reference the controlling terminal without knowing the "real" name.
stdio.h --
ctermid() - pathname of controlling terminal usually returns /dev/tty which is not useful.
unistd.h --
ttyname() - terminal name ie., pts/13 or whatever.
ttyname_r() the atomic version of ttyname
isatty() will tell you if the fd of the stream is attached to a terminal.
code fragment
Code:#include <unistd.h>
#include <stdio.h>
char *mytty;
if((mytty=ttyname(STDIN_FILENO))==NULL)
{
printf("Not a tty\n");
}
else
{
printf("%s\n", mytty);
}
Great information!!!. Exactly what I was looking for. Now the list is:Quote:
To start with SUS2 compliance dictates that "/dev/tty" can be used to open or reference the controlling terminal without knowing the "real" name.
Any mac programmers out there?Code:Windows/Dos Unix / Lynix Mac
Printer PRN /dev/lp0 ?
Console CON /dev/tty ?