pty

How to control interactive console input/output from Python on Windows?

偶尔善良 提交于 2021-02-07 09:36:26
问题 I need to control a Windows program, which reads input directly from console by calling _kbhit and _getch from <conio.h> . An example of such program can be found here: https://stackoverflow.com/a/15603102/365492 On Linux I can use pty.openpty() to create new pseudo-terminal and to emulate key presses. See this example: https://code.google.com/p/lilykde/source/browse/trunk/lilykde/py/runpty.py On Windows I tried to write to CONIN$ / CONOUT$ but all I can see is that my data is appearing on

How can I use PHP to setup an interactive SSH session?

巧了我就是萌 提交于 2021-02-07 08:37:45
问题 I'm trying to establish an interactive SSH connection to a remote server using PHP via the command line on Mac OS X 10.6. I'm currently using PHP's proc_open function to execute the following command: ssh -t -t -p 22 user@server.com This almost works. The -t -t options are supposed to force a pseudo terminal which they almost do. I am able to enter the SSH password and press enter. However, after pressing enter the terminal appears to simply hang. No output, no nothing - it's as if the SSH

Issuing commands to psuedo shells (pty)

元气小坏坏 提交于 2021-02-04 21:34:22
问题 I've tried to use the subprocess, popen, os.spawn to get a process running, but it seems as though a pseudo terminal is needed. import pty (master, slave) = pty.openpty() os.write(master, "ls -l") Should send "ls -l" to the slave tty... I tried to read the response os.read(master, 1024), but nothing was available. EDIT: Also tried to create pty's, then open the call in a subprocess -- still didn't work. import pty import subprocess (master, slave) = os.openpty() p = subprocess.Popen("ls",

attach a terminal to a process running as a daemon (to run an ncurses UI)

落花浮王杯 提交于 2021-02-02 10:00:41
问题 I have a (legacy) program which acts as a daemon (in the sense it runs forever waiting for requests to service) but which has an ncurses based user interface which runs on the host. I would like to alter the program such that if I connect to the host via ssh I can enable the user interface on demand. I know there is at least one way using pseudo-terminals but I'm not quite sure how to achieve it. There are two application behaviours I consider interesting: Run the UI only if the application

attach a terminal to a process running as a daemon (to run an ncurses UI)

眉间皱痕 提交于 2021-02-02 10:00:01
问题 I have a (legacy) program which acts as a daemon (in the sense it runs forever waiting for requests to service) but which has an ncurses based user interface which runs on the host. I would like to alter the program such that if I connect to the host via ssh I can enable the user interface on demand. I know there is at least one way using pseudo-terminals but I'm not quite sure how to achieve it. There are two application behaviours I consider interesting: Run the UI only if the application

What can you do with a pty?

风格不统一 提交于 2021-01-19 08:52:45
问题 Having read various resources including http://www.linusakesson.net/programming/tty/ I am still confused and curious about the structure and use of pseudo-terminals In a linux terminal (bash not tty) we have three streams: stdin stdout stderr There is a file descriptor for each one. These file descriptors map to streams FILE*. For example, we can use fileno() and fdopen() to switch between them. What can I do with a pty? I normally think of stdout, stdin and stderr being associated with a

What can you do with a pty?

你说的曾经没有我的故事 提交于 2021-01-19 08:51:43
问题 Having read various resources including http://www.linusakesson.net/programming/tty/ I am still confused and curious about the structure and use of pseudo-terminals In a linux terminal (bash not tty) we have three streams: stdin stdout stderr There is a file descriptor for each one. These file descriptors map to streams FILE*. For example, we can use fileno() and fdopen() to switch between them. What can I do with a pty? I normally think of stdout, stdin and stderr being associated with a

What can you do with a pty?

社会主义新天地 提交于 2021-01-19 08:51:06
问题 Having read various resources including http://www.linusakesson.net/programming/tty/ I am still confused and curious about the structure and use of pseudo-terminals In a linux terminal (bash not tty) we have three streams: stdin stdout stderr There is a file descriptor for each one. These file descriptors map to streams FILE*. For example, we can use fileno() and fdopen() to switch between them. What can I do with a pty? I normally think of stdout, stdin and stderr being associated with a

ncurses newterm following openpty

依然范特西╮ 提交于 2020-12-27 06:16:20
问题 I am trying to figure out how to do the following: create a new pseudo-terminal open a ncurses screen running inside the (slave) pseudo terminal fork A) forward I/O from the terminal the program is running in (bash) to the new (slave) terminal OR B) exit leaving the ncurses program running in the new pty. Can anyone provide pointers to what I might be doing wrong or that would make sense of some of this or even better an example program using newterm() with either posix_openpt(), openpty() or

Is there a way to connect a shell to a pseudo tty?

落花浮王杯 提交于 2020-12-15 04:03:09
问题 If I have a (compiled) background process (on GNU/Linux) such as a daemon create a pseudo-tty for itself, using openpty() or similar, is there a way to connect to it from the shell, for example to open a command line oriented interface (e.g. for debugging / re-configuring it on the fly). This is very similar to what is asked here: How to create pty that is connectable by Screen app in Linux Someone suggests an answer where they connect to it using screen and minicom but it is not that clear