pty

Executing string sent from one terminal in another in Linux pseudo-terminal

。_饼干妹妹 提交于 2019-12-02 13:14:47
Lets say I have one terminal where the output of "tty" is "/dev/pts/2" From another terminal, I want to send a command to the first terminal and execute it. Using: echo "ls" > "/dev/pts/2" only prints "ls" in the first terminal Is there a way to execute the string? No; terminals don't execute commands. They're just channels for data. You can sort of run a command and attach it to another terminal like this, though: ls </dev/pts/2 >/dev/pts/2 2>/dev/pts/2 It won't behave exactly like you ran it from that terminal, though, as it won't have that device set as its controlling terminal. It's

pty terminal packet mode TIOCPKT

回眸只為那壹抹淺笑 提交于 2019-12-02 05:06:10
问题 If I start a terminal, how do I know what mode it starts in? Who decides that? Can I start my terminal in packet mode i.e. TIOCPKT I came across this Packet mode link which says: Packet mode is enabled by pushing the pckt module on the master-side. - I do not understand this exactly. 回答1: The link you refer to is for SCO Unix, which has the STREAMS I/O subsystem. There is a pretty good overview of STREAMS here (its for Solaris, but same concepts apply to other *nixes). The manual page tells

pty terminal packet mode TIOCPKT

孤者浪人 提交于 2019-12-02 00:47:57
If I start a terminal, how do I know what mode it starts in? Who decides that? Can I start my terminal in packet mode i.e. TIOCPKT I came across this Packet mode link which says: Packet mode is enabled by pushing the pckt module on the master-side. - I do not understand this exactly. The link you refer to is for SCO Unix, which has the STREAMS I/O subsystem. There is a pretty good overview of STREAMS here (its for Solaris, but same concepts apply to other *nixes). The manual page tells you that you have to push the pckt module onto the stream, which is done with an ioctl() call with the I_PUSH

Can't change terminal size on pty/N (works on ttyN)

独自空忆成欢 提交于 2019-12-01 23:20:26
问题 I use the next to change terminal size: rc = ioctl(fd, TIOCSWINSZ, &ws); When I run this under linux text terminal (switching by Alt-Ctrl-F1), the result is that I expect to see. The whole my input and output within ranges given by ioctl syscall. But when I connect to localhost by SSH, and run the same program, it works only partly. I mean that I can't input command wider than terminal size set by ioctl, but the output can cross the borders of terminal given by ioctl, and input can take more

Simplest way to get a PTY in Linux C++

99封情书 提交于 2019-12-01 21:35:16
I am programming something that needs an interface to Bash. At first I thought I could just use popen or QProcess. ( I'm using QT C++ ) They work fine but I can't get them to run Bash in a tty, which you need if you are going to use anything like sudo, which requires a tty/pty to accept a password. I found some things like forkpty(), openpty(), etc. in the GNU Standard C libraries, but could not figure out how to use them or find any good examples, even after reading their corresponding manpages. Literally, all this part of my program needs to do is be able to read/write from a tty running

Troubleshooting OSError: out of pty devices

爷,独闯天下 提交于 2019-12-01 17:25:28
From time to time I'm getting an OSError exception with the message 'out of pty devices' when calling pty.openpty() (it's happening when a bunch of instances of my scripts run concurrently). What is the limit that I'm hitting? How can I get around this? CentOS 5.6, Python 2.4 In my Ubuntu Linux, the max number of open ptys is given by: cat /proc/sys/kernel/pty/max This value is configurable in: /etc/sysctl.conf All this info, and much more can be found in: man pty Same issue is raised when devpts is not mounted, usually in chroots, to mount devpts device type: # mount -t devpts none /path/to

Can I run jshell inside Unix expect?

久未见 提交于 2019-12-01 11:15:59
I'd like to redirect jshell input using expect, so that I can simulate typing in recorded demonstrations. But although I can spawn a jshell process from an expect script, which can also recognise the jshell prompt, after that nothing works. expect outputs what looks like a control sequence, like ^[[24;9R , and I don't see any output from jshell. Different terminal types produce different character sequences, but none of them work. This behaviour is consistent between expect on Ubuntu and Mac OS. Any suggestions for how to investigate this problem would be welcome. expect -d doesn't help. Here

Can I run jshell inside Unix expect?

限于喜欢 提交于 2019-12-01 09:18:27
问题 I'd like to redirect jshell input using expect, so that I can simulate typing in recorded demonstrations. But although I can spawn a jshell process from an expect script, which can also recognise the jshell prompt, after that nothing works. expect outputs what looks like a control sequence, like ^[[24;9R , and I don't see any output from jshell. Different terminal types produce different character sequences, but none of them work. This behaviour is consistent between expect on Ubuntu and Mac

When pty [Pseudo terminal] slave fd settings are changed by “tcsetattr” , how can the master end capture this event without delay?

跟風遠走 提交于 2019-12-01 05:15:18
The slave fd is used by another application (say "A") as a serial port device . A will set its baud rate/stop bit etc. My app needs this information . BTW, is there any way for a process that has only the master fd open to be notified of all ioctl() calls that are issued to the slave fd ? Yes, this is possible (in Linux and pre-2004 FreeBSD) , using the pty in packet mode and setting the EXTPROC flag on it. Packet mode is enabled on the master end by ioctl(master, TIOCPKT, &nonzero) . Now every read on the master end will yield a packet : whatever was written on the other side, plus a status

When pty [Pseudo terminal] slave fd settings are changed by “tcsetattr” , how can the master end capture this event without delay?

烈酒焚心 提交于 2019-12-01 02:54:27
问题 The slave fd is used by another application (say "A") as a serial port device . A will set its baud rate/stop bit etc. My app needs this information . BTW, is there any way for a process that has only the master fd open to be notified of all ioctl() calls that are issued to the slave fd ? 回答1: Yes, this is possible (in Linux and pre-2004 FreeBSD) , using the pty in packet mode and setting the EXTPROC flag on it. Packet mode is enabled on the master end by ioctl(master, TIOCPKT, &nonzero) .