tty

Why do I have to type ctrl-d twice? [duplicate]

早过忘川 提交于 2019-12-05 11:26:43
问题 This question already has answers here : Why do I have to press Ctrl+D twice to close stdin? (5 answers) Closed 5 years ago . For my own amusement, I've cooked up a python script that allows me to use python for bash one-liners; Supply a python generator expression; and the script iterates over it. Here's the script: DEFAULT_MODULES = ['os', 're', 'sys'] _g = {} for m in DEFAULT_MODULES: _g[m] = __import__(m) import sys sys.stdout.writelines(eval(sys.argv[1], _g)) And here's how you might use

Is it possible to accept user input as part of a remote git post-receive hook?

守給你的承諾、 提交于 2019-12-05 10:20:35
I've got a post-receive hook that deploys our master branch whenever we push master. I'd like to make the deployment optional; the hook asks for simple Y/N response to achieve this; bash pseudo code below: echo "Should I deploy this code now? Enter Y/N" read deploy_code case ${deploy_code} in "Y") do_a_deploy ;; "N") exit ;; *) # ask the question again if not Y or N ;; esac Because of the way the post-receive hook gets its arguments on stdin the read line doesn't pause for input from the user, and the script loops round and round trying to get a Y/N answer. I thought that specifically

How to I detect whether a tty belonging to a gsm/3g-modem is a data or control port?

久未见 提交于 2019-12-05 06:07:02
I'm currently writing a small tool for a linux router that sets up a wwan (gsm/3g) connection when I plug an appropriate modem into its USB port. When the device is plugged in several ttys are registered and I currently maintain a list of manufacturers and devices and which of their registered ttys is the control / data port. If possible I want to get rid of this list and find a way to somehow probe the registered ttys directly to check if they are a control port or a data port. I examined the sourcecode of wvdial and modem-manager to see how these tools detect the right port but was unable to

Why can't I open/write from a serial port on Android?

拟墨画扇 提交于 2019-12-04 17:28:16
I have written an Android app which runs on a custom kernel on Android 4.4 Kitkat device, which uses the Android Serial Port API ( https://code.google.com/p/android-serialport-api/ ) in order to open the serial port "/dev/ttyACM0" which is the port associated with my serial device. The port has the proper "666" permissions (crw-rw-rw), and the app itself even has the WRITE_EXTERNAL_STORAGE" permission. However, even though the permissions appear correct, when my app tries to open said serial port using the library, it fails. In my java code, if I try to do a "device.canWrite()" it returns

Is low latency mode safe to use with Linux serial ports?

拜拜、爱过 提交于 2019-12-04 10:50:01
Is it safe to use the low_latency tty mode with Linux serial ports? The tty_flip_buffer_push function is documented that it "must not be called from IRQ context if port->low_latency is set." Nevertheless, many low-level serial port drivers call it from an ISR whether or not the flag is set. For example, the mpc52xx driver calls flip buffer unconditionally after each read from its FIFO. A consequence of the low latency flip buffer in the ISR is that the line discipline driver is entered within the IRQ context. My goal is to get latency of one millisecond or less, reading from a high speed

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

我与影子孤独终老i 提交于 2019-12-04 06:57:42
问题 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? 回答1: 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

How to set a non-standard baudrate on a serial port device on Linux?

只愿长相守 提交于 2019-12-04 05:51:44
问题 What are the ways of setting custom baudrates on Linux? An answer to this question must be at a level of userland low-level APIs ( ioctl , etc.) above the level of a syscall. It should be useful in these circumstances at least: Writing low-level C-based userland code that uses serial ports, Writing libraries that abstract the serial port functionality, Writing kernel serial port drivers. 回答1: Things are, unfortunately, driver-dependent. Good drivers will implement all of the methods below.

USB Modem is echoing back wrong characters

笑着哭i 提交于 2019-12-04 04:17:02
问题 I have a USB modem connected on port ttyACM0. When I open an application like Minicom and try to send it some commands, the echo back is not always what I type. For example, if I type in "A", I get "@". If I type in "T", I do get "T". It seems that the serial port is stripping the least significant bit off of my transmission. For example: A = @ B = B C = B D = D E = D F = F ... and so on. I assume there is something wrong with my serial port configuration, but I've tried what seems like every

JSCH sudo su command “tty” error

只愿长相守 提交于 2019-12-04 02:59:18
问题 Java - Jsch sudo command. I am using Jsch and my task is to login to server and run command as following sudo su - bumboo Using following code i am successfully able to connect but when i try to run command it gives me error sudo: sorry, you must have a tty to run sudo Following is my code public static Channel sudoBamboo(Session session, String sudo_pass) throws Exception { ChannelExec channel = (ChannelExec) session.openChannel("exec"); //SUDO to bamboo user String command = "sudo su -

Why do I have to type ctrl-d twice? [duplicate]

时间秒杀一切 提交于 2019-12-03 23:19:24
This question already has answers here : Closed 5 years ago . Why do I have to press Ctrl+D twice to close stdin? (5 answers) For my own amusement, I've cooked up a python script that allows me to use python for bash one-liners; Supply a python generator expression; and the script iterates over it. Here's the script: DEFAULT_MODULES = ['os', 're', 'sys'] _g = {} for m in DEFAULT_MODULES: _g[m] = __import__(m) import sys sys.stdout.writelines(eval(sys.argv[1], _g)) And here's how you might use it. $ groups | python pype.py '(l.upper() for l in sys.stdin)' DBORNSIDE $ For the intended use, it