tty

Run command and get its stdout, stderr separately in near real time like in a terminal

亡梦爱人 提交于 2019-11-26 11:50:58
I am trying to find a way in Python to run other programs in such a way that: The stdout and stderr of the program being run can be logged separately. The stdout and stderr of the program being run can be viewed in near-real time, such that if the child process hangs, the user can see. (i.e. we do not wait for execution to complete before printing the stdout/stderr to the user) Bonus criteria: The program being run does not know it is being run via python, and thus will not do unexpected things (like chunk its output instead of printing it in real-time, or exit because it demands a terminal to

Piping data to Linux program which expects a TTY (terminal)

别来无恙 提交于 2019-11-26 11:09:50
问题 I have a program in Linux which refuses to run if its stdin/stdout is not a TTY (terminal device). Is there an easy-to-use tool which will create a PTY, start the program with the newly created TTY, and copy all data over stdin/stdout? The use case is not interactive, but scripting. I\'m looking for the most lightweight solution, preferably not creating TCP connections, and not requiring too many other tools and libraries to be installed. 回答1: unbuffer , part of expect ( sudo apt-get install

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

谁都会走 提交于 2019-11-26 10:04:13
问题 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

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

感情迁移 提交于 2019-11-26 09:30:50
问题 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

Confused about Docker -t option to Allocate a pseudo-TTY

*爱你&永不变心* 提交于 2019-11-26 08:42:41
问题 What exactly does this option do? I\'ve been reading a lot on TTY and am still confused. I played around with not having the -t and just -i and it seems like programs that expect user input throw an error without the -t . Why is it important for pseudo-TTY to be enabled? 回答1: The -t option goes to how Unix/Linux handles terminal access. In the past, a terminal was a hardline connection, later a modem based connection. These had physical device drivers (they were real pieces of equipment).

Run interactive Bash with popen and a dedicated TTY Python

不想你离开。 提交于 2019-11-26 08:25:34
问题 I need to run an interactive Bash instance in a separated process in Python with it\'s own dedicated TTY (I can\'t use pexpect). I used this code snippet I commonly see used in similar programs: master, slave = pty.openpty() p = subprocess.Popen([\"/bin/bash\", \"-i\"], stdin=slave, stdout=slave, stderr=slave) os.close(slave) x = os.read(master, 1026) print x subprocess.Popen.kill(p) os.close(master) But when I run it I get the following output: $ ./pty_try.py bash: cannot set terminal

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

 ̄綄美尐妖づ 提交于 2019-11-26 05:57:13
问题 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? I wrote a script (\' print_timer.py \' at the bottom of this question) to compare timing when writing 100k lines to stdout, to file, and with stdout

Run command and get its stdout, stderr separately in near real time like in a terminal

大城市里の小女人 提交于 2019-11-26 02:37:12
问题 I am trying to find a way in Python to run other programs in such a way that: The stdout and stderr of the program being run can be logged separately. The stdout and stderr of the program being run can be viewed in near-real time, such that if the child process hangs, the user can see. (i.e. we do not wait for execution to complete before printing the stdout/stderr to the user) Bonus criteria: The program being run does not know it is being run via python, and thus will not do unexpected

How to fix &#39;sudo: no tty present and no askpass program specified&#39; error?

落花浮王杯 提交于 2019-11-26 01:22:20
问题 I am trying to compile some sources using a makefile. In the makefile there is a bunch of commands that need to be ran as sudo . When I compile the sources from a terminal all goes fine and the make is paused the first time a sudo command is ran waiting for password. Once I type in the password, make resumes and completes. But I would like to be able to compile the sources in NetBeans. So, I started a project and showed netbeans where to find the sources, but when I compile the project it