tty

How to open a tty device in noncanonical mode on Linux using .NET Core

你离开我真会死。 提交于 2020-06-29 03:51:16
问题 I'm using .NET Core on an embedded Linux platform with good success so far. I just ran into a problem with trying to open a tty device in raw (noncanonical mode) though. If I was using regular C or C++ I would call cfmakeraw() after opening the device, but how do I do that from a .NET Core app? The device I need to work with is a CDC ACM function driver for the USB client connector, i.e. it's a virtual COM port. It appears in my system as /dev/ttyGS0 . I can open the device and then read from

Determine terminal/TTY background color at runtime

浪子不回头ぞ 提交于 2020-06-22 18:01:48
问题 Using the chalk library to stylize/colorize the terminal. import chalk from 'chalk'; if I use: console.log(chalk.blue('foobar')); that's totally readable in a terminal with a light background, but totally unreadable in a terminal with a dark background. Is there some way to determine the background color of a terminal at runtime? Example given: The "npm notice" log level is a case of this problem: It's difficult to read the blue on black. 回答1: The following is a generic answer, about ANSI

In a script how to get the pid of spawned terminal's shell to execute commands in it using ttyecho?

随声附和 提交于 2020-04-30 10:01:54
问题 I am using ttyecho (can be installed with yay -S ttyecho-git ) to execute a command in a separate terminal like so: urxvt & sudo ttyecho -n /proc/<pid-of-new-urxvt>/fd/0 <command> It does not work because the /proc/pid-of-new-urxvt/fd/0 is a symlink that points to the /dev/pts/x of the parent terminal. In the spawned urxvt I happen to run zsh. So if I use the pid of that zsh process it works: sudo ttyecho -n /proc/<pid-of-new-zsh-within-new-urxvt>/fd/0 <command> How can I get the pid of the

Why can't I retrieve my program that was suspended from inside backticks?

孤人 提交于 2020-03-05 04:28:46
问题 I created a program that takes a list of arguments and put them in a grid on a new tty where I can move around and select from it what I want. When I run the program without backticks like this... $> ./ft_select arg_1 arg_2 ... arg_N A new tty is opened and a grid is shown... arg_1 arg_2 arg_3 arg_4 arg_5 arg_6 arg_7 ... arg_N I hit ctrl+z and the program gets suspended with no problem and fg command puts it back. My problem is that when I put the command between backticks and I try to

Why can't I retrieve my program that was suspended from inside backticks?

三世轮回 提交于 2020-03-05 04:28:07
问题 I created a program that takes a list of arguments and put them in a grid on a new tty where I can move around and select from it what I want. When I run the program without backticks like this... $> ./ft_select arg_1 arg_2 ... arg_N A new tty is opened and a grid is shown... arg_1 arg_2 arg_3 arg_4 arg_5 arg_6 arg_7 ... arg_N I hit ctrl+z and the program gets suspended with no problem and fg command puts it back. My problem is that when I put the command between backticks and I try to

Write program that pretends to be a TTY

余生长醉 提交于 2020-01-30 04:10:49
问题 I'm writing a program that reads input from stdin, manipulates the input, and writes output to stdout. However, many programs check whether stdin is a terminal or a pipe (by calling a function like isatty), and generate output differently. How do I have my program pretend to be a TTY? The solution should work on both Linux and macOS. Any programming language that generates a standalone binary is acceptable, but Go is preferred. Note that I'm asking a programming question, not asking for a

subprocess.Popen for “ssh sudo -u user -i” is failing with “sudo: sorry, you must have a tty to run sudo”

二次信任 提交于 2020-01-13 05:11:09
问题 I want to ssh into a remote server, change user then execute a script. I'm using subprocess to do this but it appears sudo -u userB -i is not changing user. HOST = 'remote_server' USER = 'userA' CMD = ' whoami; sudo -u userB -i; whoami' ssh = subprocess.Popen(['ssh', '{}@{}'.format(USER, HOST),CMD], shell=False, stdout=subprocess.PIPE, stderr=subprocess.PIPE) result = ssh.stdout.readlines() if not result: err = ssh.stderr.readlines() print('ERROR: {}'.format(err)) else: print "success" print

enabling tty in a ssh session

China☆狼群 提交于 2020-01-12 08:47:09
问题 I would to take in some login information for a script have written in to be used by many users. In python I set the input_raw to read from dev/tty but it fails horribly when i am connecting to the script being run on a server through ssh. Thoughts? Workarounds? I would prefer to avoid hard coding usernames into the script. Please and thank you. 回答1: Try using the -t option to ssh: -t Force pseudo-tty allocation. This can be used to execute arbi- trary screen-based programs on a remote

How to run command during Docker build which requires a tty?

别等时光非礼了梦想. 提交于 2020-01-11 05:13:06
问题 I have some script I need to run during a Docker build which requires a tty (which Docker does not provide during a build). Under the hood the script uses the read command. With a tty, I can do things like (echo yes; echo no) | myscript.sh . Without it I get strange errors I don't completely understand. So is there any way to use this script during the build (given that its not mine to modify?) EDIT: Here's a more definite example of the error: FROM ubuntu:14.04 RUN echo yes | read which

Catching a direct redirect to /dev/tty

假如想象 提交于 2020-01-11 03:05:10
问题 I'm working on an application controller for a program that is spitting text directly to /dev/tty. This is a production application controller that must be able to catch all text going to the terminal. Generally, this isn't a problem. We simply redirect stdout and stderr. This particular application is making direct calls to echo and redirecting the result to /dev/tty ( echo "some text" > /dev/tty ). Redirects via my application controller are failing to catch the text. I do have the source