tty

What is the purpose of the “-i” and “-t” options for the “docker exec” command?

痴心易碎 提交于 2019-11-27 02:51:36
问题 To be honest, I have always been confused about docker exec -it … , docker exec -i … and docker exec -t … , so I decide to do a test: docker exec -it … : # docker exec -it 115c89122e72 bash root@115c89122e72:/# ls bin boot dev etc home lib lib64 media mnt opt proc root run sbin srv sys tmp usr var It works normally. docker exec -i … : # docker exec -i 115c89122e72 bash ^C The command hangs and I have to use Ctl + c to interrupt it. docker exec -t … : # docker exec -t 115c89122e72 bash root

How to enter in a Docker container already running with a new TTY

核能气质少年 提交于 2019-11-27 02:28:14
I have a container that is running the Apache service in the foreground. I would like to be able to access the container from another shell in order to "poke around" inside it and examine the files. At the moment, if I attach to the container, I am left looking at the Apache daemon and cannot run any commands. Is it possible to attach another tty to a running container? Possibly, I can take advantage of the fact that Docker is actually just wrapping around LXC containers? I have tried sudo lxc-console -n [container-id] -t [1-4] but it appears that only one tty is made available and that is the

AT^SYSINFO and a C++ terminal program

泪湿孤枕 提交于 2019-11-27 02:18:52
I have written a program that comminucates serially with a USB 3g Modem. When I open the port and write the AT command AT To the modem, I get the normal "OK" response and can read it using a serial read function. In a terminal, when I write the command AT^SYSINFO I get the following response: ^SYSINFO:#,#,#,#,#,# With the #'s being numbers. However, when I attempt to write the same command serially using my program, I read only this reponse: AT^SYSINFO I try to then read another line of incoming data, but no data comes. Can anyone help me with this? There is information in the ^SYSINFO message

Receiving key press and key release events in Linux terminal applications?

时间秒杀一切 提交于 2019-11-27 02:08:22
问题 I would like to write a simple C program that will perform different actions based on both "key down" and "key up" events. This program will be run from inside rxvt. What library or mechanism should I use to access both key presses and releases? Is it true that reading /dev/tty will only provide key releases? Is this also true for termcap, terminfo, ncurses, and slang? Is there a way to achieve this from within a terminal application? 回答1: The following links may be of some assistance in

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

落爺英雄遲暮 提交于 2019-11-27 00:57:59
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 input (and pressing enter), the output I am getting is: input# foo Read from STDIN: f input# Read from STDIN: o input# Read from STDIN: o input# Read from STDIN: input# The output I am expecting is: input# f input# Read from STDIN: f input# o input# Read from STDIN: o

Reading and writing to serial port in C on Linux

早过忘川 提交于 2019-11-26 19:29:36
I'm trying to send/receive data over an USB Port using FTDI , so I need to handle serial communication using C/C++. I'm working on Linux (Ubuntu). Basically, I am connected to a device which is listening for incoming commands. I need to send those commands and read device's response. Both commands and response are ASCII characters . Everything works fine using GtkTerm but, when I switch to C programming, I encounter problems. Here's my code: #include <stdio.h> // standard input / output functions #include <stdlib.h> #include <string.h> // string function definitions #include <unistd.h> // UNIX

MacOS: what's the difference between /dev/tty.* and /dev/cu.*?

不羁岁月 提交于 2019-11-26 19:00:55
问题 Each serial device shows up twice in /dev , once as a tty.* and once as a cu.* . What is the cu.* device? How does it differ from the tty.* device? mh@maru ~ --> ls -l /dev/*.usbmodem621 crw-rw-rw- 1 root wheel 11, 5 Dec 25 18:00 /dev/cu.usbmodem621 crw-rw-rw- 1 root wheel 11, 4 Dec 25 18:00 /dev/tty.usbmodem621 回答1: http://lists.berlios.de/pipermail/gpsd-dev/2005-April/001288.html : The idea is to supplement software in sharing a line between incoming and outgoing calls. The callin device

How to write data to existing process's STDIN from external process?

别来无恙 提交于 2019-11-26 17:42:50
问题 I'm seeking for ways to write data to the existing process's STDIN from external processes, and found similar question How do you stream data into the STDIN of a program from different local/remote processes in Python? in stackoverlow. In that thread, @Michael says that we can get file descriptors of existing process in path like below, and permitted to write data into them on Linux. /proc/$PID/fd/ So, I've created a simple script listed below to test writing data to the script's STDIN (and

What do pty and tty mean?

孤街醉人 提交于 2019-11-26 14:58:37
问题 I noticed there are many mentions of pty and tty in some opensource projects, could someone can tell me what do they mean and what is the difference between them? Thanks! 回答1: "tty" originally meant "teletype" and "pty" means "pseudo-teletype". In UNIX, /dev/tty* is any device that acts like a "teletype", ie, a terminal. (Called teletype because that's what we had for terminals in those benighted days.) A pty is a pseudotty, a device entry that acts like a terminal to the process reading and

How do *nix pseudo-terminals work ? What&#39;s the master/slave channel?

混江龙づ霸主 提交于 2019-11-26 13:03:28
问题 I want to write a simple, dumb, X terminal emulator in C on a Linux system. At first, I just thought I would have to popen a shell and display its output. I checked xterm and rxvt code, and it looks a bit more complicated. First, I have to open a pseudo-terminal with openpty. So I look at the man page and see that openpty fills 2 file descriptors, the master and the slave. Both xterm and rxvt code are messy because of the system-dependent-ness of those specials files. I understand the termios