tty

How to tell if running in a linux console versus an ssh session?

Deadly 提交于 2019-12-01 03:51:19
I have an application that needs to behave differently if run directly from the linux console. So if a user connects with SSH to run FooBar, or the user walks over to the console and logs in directly to run FooBar, I want it to do something different. What C API do I need to call to tell the difference between these two scenarios? I was thinking I'd have to look at the "tty/pts" information (such as what I see when I run "ps axf"), but I'm not certain if that is the best solution, nor what API to call to get that information. Hints appreciated. :) Checking the return value of ttyname(3)

Set stty parameters

╄→尐↘猪︶ㄣ 提交于 2019-12-01 03:11:50
问题 Im trying to use bash to read from ttyS0 and need to set the following but im struggling to figure it out databits = 7 stopbits = 2 parity = 0 flow control = 0 heres my code: #!/bin/bash # Port setting stty -F /dev/ttyS0 raw speed 1200 # Loop while [ 1 ]; do echo 'LOADING...' READ=`dd if=/dev/ttyS0 count=1` echo $READ echo '[PRESS Ctrl + C TO EXIT]' done The script is working but I need to set the parameters. Any suggestions? And thanks:) 回答1: try stty -F /dev/ttyS0 cs7 cstopb -ixon raw speed

GoLang - termbox: panic: open /dev/tty: no such device or address

我的未来我决定 提交于 2019-12-01 01:32:10
I am coding with Go 1.2 on Ubuntu 12.04 LTS machine - using LiteIDE (very pleased with it). I downloaded and installed the go termbox package - built the demo keyboard.go - built fine. But when I run from LiteIDE, I get this panic - same happens with all the termbox demos: panic: open /dev/tty: no such device or address Any clues would be helpful.... OK, that's completely reasonable: interactive terminal applications require, well, terminal to be available. Terminals may be real— hardware —or virtual (like Linux virtual terminals you see on a typical x86 box when you hit Ctrl-Alt-F1) or

How to tell if running in a linux console versus an ssh session?

独自空忆成欢 提交于 2019-12-01 00:47:56
问题 I have an application that needs to behave differently if run directly from the linux console. So if a user connects with SSH to run FooBar, or the user walks over to the console and logs in directly to run FooBar, I want it to do something different. What C API do I need to call to tell the difference between these two scenarios? I was thinking I'd have to look at the "tty/pts" information (such as what I see when I run "ps axf"), but I'm not certain if that is the best solution, nor what

How to discard data as it is sent with boost::asio?

那年仲夏 提交于 2019-11-30 22:34:03
I'm writing some code that reads and writes to serial device using boost::asio class. However, when sending several strings between programs, I've noticed that on the receiving program the data is read in the order as it was written to the serial port, and not as the data is sent from the other program - If I start reading data some seconds later, I don't get the values that I am sending at the moment but those that were sent previously. I'm assuming this is caused by how I am setting up my boost::asio::serial_port : int main(int argc, char const *argv[]){ int baud=atoi(argv[1]); std::string

Catching a direct redirect to /dev/tty

别等时光非礼了梦想. 提交于 2019-11-30 21:20:24
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 for this application, but am not in a position to modify it, nor is it being maintained anymore. Any

GoLang - termbox: panic: open /dev/tty: no such device or address

余生长醉 提交于 2019-11-30 20:55:49
问题 I am coding with Go 1.2 on Ubuntu 12.04 LTS machine - using LiteIDE (very pleased with it). I downloaded and installed the go termbox package - built the demo keyboard.go - built fine. But when I run from LiteIDE, I get this panic - same happens with all the termbox demos: panic: open /dev/tty: no such device or address Any clues would be helpful.... 回答1: OK, that's completely reasonable: interactive terminal applications require, well, terminal to be available. Terminals may be real—hardware

sudoers NOPASSWD: sudo: no tty present and no askpass program specified

无人久伴 提交于 2019-11-30 19:03:09
I have added a user like this: $ adduser --system --home /no/home --no-create-home --group --disabled-password --disabled-login testuser Added a user to a group: $ adduser testuser testgroup added lines to sudoers (visudo): testuser ALL=(ALL) NOPASSWD: ALL %testgroup ALL=(ALL:ALL) NOPASSWD: ALL When I try to run the bash script with the following content: #!/bin/sh sudo -u testuser /usr/bin/php /usr/local/bin/script.php But when I run this script, I get the error in the log: sudo: no tty present and no askpass program specified Edit: requiretty is not in the sudoers file. sudo permissions are

How to discard data as it is sent with boost::asio?

匆匆过客 提交于 2019-11-30 18:04:00
问题 I'm writing some code that reads and writes to serial device using boost::asio class. However, when sending several strings between programs, I've noticed that on the receiving program the data is read in the order as it was written to the serial port, and not as the data is sent from the other program - If I start reading data some seconds later, I don't get the values that I am sending at the moment but those that were sent previously. I'm assuming this is caused by how I am setting up my

docker error : the input device is not a TTY. If you are using mintty, try prefixing the command with 'winpty'

雨燕双飞 提交于 2019-11-30 12:57:55
问题 After i run this $ docker run --rm -v "/c/users/vipul rao/documents/github/wappalyzer:/opt/wappalyzer" -it wappalyzer/dev I am getting the following error the input device is not a TTY. If you are using mintty, try prefixing the command with 'winpty' What should i use here i am running on windows 8 in MINGW64. 回答1: As suggested by the error message you obtain, you should try to use winpty (which is installed by default with Git-Bash) and thus run: winpty docker run --rm -v "/c/users/vipul rao