Jump to content

Check input device is a terminal: Difference between revisions

Go solution
(→‎{{header|Ruby}}: Added Ruby Header and sample)
(Go solution)
Line 67:
C:\test < in.txt
Input doesn't come from tty.</pre>
 
=={{header|Go}}==
{{libheader|Go sub-repositories}}
<lang go>package main
 
import (
"code.google.com/p/go.crypto/ssh/terminal"
"fmt"
"os"
)
 
func main() {
if terminal.IsTerminal(int(os.Stdin.Fd())) {
fmt.Println("Hello terminal")
} else {
fmt.Println("Who are you? You're not a terminal.")
}
}</lang>
{{out}}
<pre>
> hello
Hello terminal
> hello </dev/null
Who are you? You're not a terminal.
</pre>
 
=={{header|Nemerle}}==
1,707

edits

Cookies help us deliver our services. By using our services, you agree to our use of cookies.