tty

How to force input from tty

I'd like to write a program which reads user input only from tty, instead of redirected stdin pipes, like passwd and ssh do. Is there any approach? Many thanks ...

How to tell if running in a linux console versus an ssh session?

I have an application that needs to behave differently if run directly from the linux console. So if a user connects with SSH to run FooBar, or the user walks over to the console and logs in directly to run FooBar, I want it to do something different. What C API do I need to call to tell the difference between these two scenarios? I w...

Correct initialization sequence for Linux serial port

I wrote an application that must use serial ports on Linux, especially ttyUSB ones. Reading and writing operations are performed with standard select()/read() loop and write(), and there is probably nothing wrong in them, but initialization code (or absence of some part of it) damages something in the tty subsystem. Here it is: vuxbo...

Linux: can I read the output of another process without using any IPC (pipes, etc.)?

Is it possible in linux to somehow read the output (from stdout and stderr) of another process without it knowing about it? So lets say I have a process A running in the background and process B wants to read its output - is it possible? I can't use pipes or the screen program. I tried reading from /proc/xxx/fd or from /pts/x consoles an...

How to figure out whether a Linux TTY is controlling a process group

So I have a tty (let's say /dev/tty5) and want to know whether it currently is a controlling tty of a process group or session, or whether it is currently unowned. POSIX has two API functions which suggest themselves here: tcgetpgrp() and tcgetsid(), both of which only work however if the caller has the tty as controlling tty -- which in...

C write() doesn't send data until close(fd) is called.

So I have this test code to send "HELLO" over a USB serial port: int fd; struct termios tty; if((fd = open("/dev/ttyUSB0", O_WRONLY|O_NONBLOCK|O_NOCTTY)) == -1){ err(1, "Cannot open write on /dev/ttyUSB0"); } tcgetattr(fd, &tty); tty.c_iflag = 0; tty.c_oflag = 0; tty.c_lflag = 0; tty.c_cflag = 0; tty.c_cc[VMIN] = 0; tty.c_cc[VTIME] = ...

Is there a way to wait for and get a key press from a (remote) terminal session?

Hi folks, I've been playing around with some ANSI stuff (like colors etc.) in java and php (from scratch) and I'm trying to find a way to basically wait for a key press. I'd like to have something like the following pseudo code at the end of my main event loop: If (KeyPressed) Begin var event = new KeyboardEvent(); event.Ke...

persistent local tty session with java

Hello all, I`m developing a web shell client, with tab functionality "code completion" and a have a question. Anyone know a way to open a local tty persistent connection where I can to execute multiple commands with one session, i wont like to exec all time Runtime.getRuntime().exec("command"); Any suggestion? Regards ...

Interrupt-driven driver using TTY?

Hi, I am a newbie to developing drivers for Linux ... . I am developing a SMS-driver (AT commands over serial port to modem) using TTY for accessing the serial port. The driver is written in C. In the design messages from modem to driver can be triggered by two events: 1) Status as respond to AT commands issued by driver (i.e. expect...

enabling tty in a ssh session

I would to take in some login information for a script have written in to be used by many users. In python I set the input_raw to read from dev/tty but it fails horribly when i am connecting to the script being run on a server through ssh. Thoughts? Workarounds? I would prefer to avoid hard coding usernames into the script. Please and...

How can I spy on communication between a process and a terminal?

I have a Linux process developed by a third-party that communicates with a terminal. For debugging I want to see the communication going back in forth. One might think cat would do the trick (to see one direction): ./third-party-app & cat /dev/tty ...but it does not. Rather, cat will steal half of the data intended for the ...

How do I detect if stdout is connected to a tty in Perl?

I'm looking for the Perl equivalent to this Python code: from sys import stdout if stdout.isatty(): print "yes" else: print "no" ...

How to direct program prints to seprate window(shell/tty)

I am writing a console application which is using some library in which (DEBUG) prints are enabled. In my main() application I am taking inputs from user. I want this user input to be separate from my library prints. I cant disable library debug prints. (The problem is library has lots of continuous prints over which it is difficult to t...

what possible reasons could block a virtual terminal on Linux?

Or is it possible at all that some process or something else could block a virtual terminal? Or what could be a reason that an application hangs when trying to access the VT1? It seems, while that is happening, it is hanging in the function ioctl. Esp., this is the code which fails: int vtno = 1; const char* vtname = "/dev/tty1"; int ...

Detect if stdin is a tty device (terminal) or pipe in PHP?

I wrote a php script. I want it show help message when called with standard input connected to a tty device (terminal) before reading and executing interactively, but dont show when called with a file or stream from pipe as standard input. Is there a way to detect this from PHP? ...

PHP CLI: How to read a single character of input from the TTY (without waiting for the enter key)?

I want to read a single character at-a-time from the command line in PHP, however it seems as though there is some kind of input buffering from somewhere preventing this. Consider this code: #!/usr/bin/php <?php echo "input# "; while ($c = fread(STDIN, 1)) { echo "Read from STDIN: " . $c . "\ninput# "; } ?> Typing in "foo" as the...

Why is printing to stdout so slow? Can it be sped up?

I've always been amazed/frustrated with how long it takes to simply output to the terminal with a print statement. After some recent painfully slow logging I decided to look into it and was quite surprised to find that almost all the time spent is waiting for the terminal to process the results. Can writing to stdout be sped up somehow...

Java program stdout and detaching from foreground

Hi, I have a java program, let's say Test.class. When I execute java Test the program ask for a Password and then continute. The problem is that the stdout is redirected to a log and the program is launched with the & ( we are on UNIX). How can i interact with this program launched java Test & with the stdin and stdout? One possible...

C/Linux Programming: Pseudo-Terminals: how to redirect from current stdio to pty and redirect back after usage

Hi! I'm trying to create a simple remote management program where a user can connect to my little device and "take over" the current stdio of the system. For example: System boots with console=serial port --> client connects, redirect input/output to the socket I have already accomplished the redirection to network part (by reading th...