tty

Filter out command that needs a terminal in Python subprocess module

血红的双手。 提交于 2019-12-12 12:50:54
问题 I am developing a robot that accepts commands from network (XMPP) and uses subprocess module in Python to execute them and sends back the output of commands. Essentially it is an SSH-like XMPP-based non-interactive shell. The robot only executes commands from authenticated trusted sources, so arbitrary shell commands are allowed ( shell=True ). However, when I accidentally send some command that needs a tty, the robot is stuck. For example: subprocess.check_output(['vim'], shell=False)

How do I test to ensure only an integer is entered and ensure length of input is 5 bytes or less in Assembly?

徘徊边缘 提交于 2019-12-11 23:34:27
问题 How do I test to ensure only an integer is entered and ensure length of input is 5 bytes or less in the following code? I am trying to understand how to properly control input so that the input beyond 5 bytes is not outputted to the terminal upon exiting of the program. In addition, how would I test to ensure only a string is entered and finally in the last scenario, only a double is entered? *** Updated code based on x82 and Peter C's guidance. I did some C disas and was able to amend my

Run “java -jar MyJar.jar” automatically on linux server, instead of on login and run from ssh

风流意气都作罢 提交于 2019-12-11 18:14:04
问题 How can I run a Java .jar file, fx "java -jar MyJar.jar" automatically on a Linux server, instead every time I login and run it from ssh? I am looking for some way to automatically execute that command, or something to that effect. Also, how can I direct all output to some logfile? (I guess stdio in autostrt is unavailable.) 回答1: You can use the terminal hooks, like See this answers about the bashrc. When you make a login or open a new terminal on your server, the script will run and execute

What causes `read()` in `c` does not read content that being input by other processes from the current `tty`?

淺唱寂寞╮ 提交于 2019-12-11 15:17:54
问题 I imitated the check-password module from openssh source code and it uses read() to get the content from the current tty's file descriptor, here is the code: #include <unistd.h> #include <stdio.h> #include <sys/types.h> #include <sys/stat.h> #include <fcntl.h> int main () { int ttyfd=open("/dev/tty", O_RDWR); if(ttyfd>=0) printf("good to open\n"); char * a; while(read (ttyfd,a,1)){ printf("%s", a); } return 0; } It runs in a terminal like this: root@localhost:~/Desktop# tty /dev/pts/0 root

device and drivers connections

最后都变了- 提交于 2019-12-11 15:05:45
问题 There is a device that is connected to the controller uart port (in Linux 2.6), and which generates an interrupt on gpio. I wrote the driver of the Space user to communicate with the device, but I want to move this driver into the kernel. Does anyone have a similar experience? There is a driver of uart port from freescale do not really understand how this driver connects to the device through function probe (). Not yet found where the structure of the device is created and at what point and

How to do a non-blocking read on a non-socket fd

隐身守侯 提交于 2019-12-11 12:05:29
问题 Is there a way to do a single read() in non-blocking mode on a pipe/terminal/etc, the way I can do it on a socket with recv(MSG_DONTWAIT) ? The reason I need that is because I cannot find any guarantee that a read() on a file-descriptor returned as ready for reading by select() or poll() will not block. I know can make the file descriptor non-blocking with fcntl(fd, F_SETFL, fcntl(fd, F_GETFL) | O_NONBLOCK) but this will change the mode on that file descriptor globally, not just in the

Can not write to '/dev/tty' when build Docker images

我是研究僧i 提交于 2019-12-11 11:48:43
问题 I'm building docker images from Dockerfile and when I run a script(CUDA installation script) which has echo XXX > /dev/tty in it, then an error "/dev/tty: No such device or address" comes up and the build failed. I've tried --silent flag but it seems do no help. My base image is Cent OS 7. Is there anyway to fix or work around this? 回答1: I've fixed this problem: it turns out I didn't install command tar & perl before hand. And the script wants to write error messages to /dev/tty. The error

Serial port read is not complete

心不动则不痛 提交于 2019-12-11 06:14:46
问题 The functions below are used consequently to read data from serial port under Linux. I can read the complete data when I debug, but when I launch the program, read_buffer seems not to be complete. I receive the small part of the data correctly but the rest of the buffer is completely zero . What could be the problem? int8_t __serial_port_open(uint8_t *port) { mode_t perms = S_IRWXU; fd = open(port, O_RDWR | O_NOCTTY | O_SYNC, perms); if (fd < 0) { return -1; } if (__serial_port_configure() !=

How can I create a loop between two TTYs?

随声附和 提交于 2019-12-11 03:33:18
问题 Every Hello has a response. Second TTY will send a hello to the sender TTY and vice versa: echo 'echo hello > /dev/pts/1' > /dev/pts/0 The 1st receiver should send "hello" to the original sender, but it does not. What is wrong? [Clarification] I have two shells running. /dev/pts/1 is the initial sender. 回答1: When you send your echo command to /dev/pts/0 you are literally just sending the output of that echo to the other TTY's output - you are not sending it to the other TTY's input buffers.

Which Linux system calls should I use to read raw characters from stdin?

喜欢而已 提交于 2019-12-11 03:03:46
问题 I'm trying to port my stdrepl library to FASM for learning purposes. I know that the GNU readline library already does what I'm trying to do, but I want to learn how to write non-trivial programs in assembly. In node.js I can easily create a tty by writing: var stdin = process.stdin; stdin.setEncoding("utf8"); stdin.setRawMode(true); stdin.resume(); How do I achieve the same results in pure assembly. I tried reading one byte from stdin at a time in a loop as follows, but it doesn't return the