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:
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:
i don't think most standard compilers support programmers with more than 4 red boxes - Misplaced
It is my sacred duity to stand in the path of the flood of ignorance and blatant stupidity... - quzah
Such pointless tricks ceased to be interesting or useful when we came down from the trees and started using higher level languages. - Salem
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.
All the buzzt!
CornedBee
"There is not now, nor has there ever been, nor will there ever be, any programming language in which it is the least bit difficult to write bad code."
- Flon's Law
So these would be the stream names? Maybe I am not being clear, or most likely I'm stupid , lets say I wanted to open a stream, I would do it like:/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);
Last edited by andyhunter; 02-11-2005 at 08:26 AM.
i don't think most standard compilers support programmers with more than 4 red boxes - Misplaced
It is my sacred duity to stand in the path of the flood of ignorance and blatant stupidity... - quzah
Such pointless tricks ceased to be interesting or useful when we came down from the trees and started using higher level languages. - Salem
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.
All the buzzt!
CornedBee
"There is not now, nor has there ever been, nor will there ever be, any programming language in which it is the least bit difficult to write bad code."
- Flon's Law
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?
i don't think most standard compilers support programmers with more than 4 red boxes - Misplaced
It is my sacred duity to stand in the path of the flood of ignorance and blatant stupidity... - quzah
Such pointless tricks ceased to be interesting or useful when we came down from the trees and started using higher level languages. - Salem
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.
All the buzzt!
CornedBee
"There is not now, nor has there ever been, nor will there ever be, any programming language in which it is the least bit difficult to write bad code."
- Flon's Law
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.
Last edited by andyhunter; 02-11-2005 at 03:51 PM.
i don't think most standard compilers support programmers with more than 4 red boxes - Misplaced
It is my sacred duity to stand in the path of the flood of ignorance and blatant stupidity... - quzah
Such pointless tricks ceased to be interesting or useful when we came down from the trees and started using higher level languages. - Salem
Unless it's been redirected
All the buzzt!
CornedBee
"There is not now, nor has there ever been, nor will there ever be, any programming language in which it is the least bit difficult to write bad code."
- Flon's Law
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?
i don't think most standard compilers support programmers with more than 4 red boxes - Misplaced
It is my sacred duity to stand in the path of the flood of ignorance and blatant stupidity... - quzah
Such pointless tricks ceased to be interesting or useful when we came down from the trees and started using higher level languages. - Salem
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.
All the buzzt!
CornedBee
"There is not now, nor has there ever been, nor will there ever be, any programming language in which it is the least bit difficult to write bad code."
- Flon's Law
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); }
Last edited by jim mcnamara; 02-11-2005 at 04:27 PM.
Great information!!!. Exactly what I was looking for. Now the list is: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 ?
i don't think most standard compilers support programmers with more than 4 red boxes - Misplaced
It is my sacred duity to stand in the path of the flood of ignorance and blatant stupidity... - quzah
Such pointless tricks ceased to be interesting or useful when we came down from the trees and started using higher level languages. - Salem