I‘ve successfully implemented a PTY (Pseudo Terminal) Function: master and slave which successfully communicate. But often when I read data from the slave, it appears to be echoing. Is there any way how to disable this ? After some research I found out, that this is possible changing the flags of the termios struct: StructTermios.c_lflag = 0;  Unfortunately I didn‘t manage to disable echo in the PTY () Is there any way to do so, any ideas, suggestions, proposals, websites ... ? I would love to hear from you ❤️, Regards, from Brooks (~)
124020
On linux, I am opening a pseudo tty on the master side. While there is no client on the slave side, the pseudo tty seems to be echoing everything I am writing to him, which is not what I am expecting. Consider the folowing code :  int  main(int argc, char * argv[]) {     int ptyfd;     int rc;     /* return code */     char readbuf[3];     ptyfd = open("/dev/ptmx", O_RDWR | O_NOCTTY);     die_on_error(ptyfd, "open ptmx");      /* unlock and print slave name */     rc = unlockpt(ptyfd);     die_on_error(rc, "unlockpt");     printf("Slave pts name : %s\n", ptsname(ptyfd));      write(ptyfd, "C", 1);     rc=read(ptyfd, readbuf, 1);     die_on_error(rc, "read");     printf("read returned %c\n",readbuf[0]);     return 0;    }   When I run this program, I would expect the read call to block, but instead it immediately returns and the readbuf content is C. How can I change this behaviour ? When the slave side is not opened, I would like the character written on the master side to either vanish or be fifoed for later reading by the slave side.  Is changing the master side attributes the right way to do it ?
71344
I have a few remote servers which I connect to through the terminal. The servers don't have a domain, only an IP address which is hard to remember when I got a few of them.  Is there a way to permanently store values in the terminal, so that I can do the following?  server1 = 111.222.111.222   And type commands like:  ssh root@server1   instead of:  ssh root@111.222.111.222
21443
Is there any standard that covers the portability of running a command after variable assignment on the same line?  APPLE="cider" echo hi   How portable is something like that? Where will it work and where won't it?   Also: my shell scripts start with #!/bin/sh if that makes any difference.
50075
Is there a way to disable scrolling through command history for the Xfce terminal? I don't wish to rely on palm rejection, I'd just like it disabled when I'm using the terminal. Specifically I'm talking about not cycling through previous commands at the prompt when scrolling with mouse/touchpad.
43641
Everytime I try to sudo something at the terminal, I get a warning message:  alexandre@XPS-15Z $ sudo mount file.iso /mnt/ -o loop [sudo] password for alexandre:  no talloc stackframe at ../source3/param/loadparm.c:4864, leaking memory   It's just annoying to get that all the time. How do I solve that? I'm on Ubuntu 14.04 (upgraded from 13.10)
98206
"Everything is a file" in the UNIX World.  Above sentence is famous. When I run echo "hello programmer" &gt;&gt; /dev/tty1 , I can watch the given string on TeleType 1  , ....  What and where is file per each socket? Suppose my friend connects to my PC, and its IP is h.h.h.h , how can I access the respective file? Is it possible?
73904
When is it a good idea to use ?  I sometimes see this in code samples of PHP. Does this handle DOS/Mac/Unix endline issues?
40060
Some commands are provided as both builtins and external utilities. Take echo for example. On my machine (macOS) running Bash 3.2,  $ type echo echo is a shell builtin   Running man bash | less --pattern='^ *echo +\[' shows:   echo [-neE] [arg ...]    But running man 1 echo shows a man page for a different implementation of echo, with a different signature:   echo [-n] [string ...]    I'm able to use -e successfully, so I must be running the builtin, and presumably that's /bin/echo  $ which echo /bin/echo   Where does the other implementation live, and how can I distinguish between builtins and external utils in general (e.g. printf)  Update/Correction Thanks @Gilles for clarifying. And the proof is in the pudding!  $ /bin/echo -e "\tabc" -e \tabc  $ echo -e "\tabc"         abc
118188
I tried the following command after watch  on pipe shenanigans.  man -k . | dmenu -l 20 | awk '{print $1}' | xargs -r man -Tpdf | zathura -   It basically prints a list of manpages to dmenu for the user to select one of them, then it uses xargs to run man -Tpdf % (print to stdout a pdf of the manpage git from the xargs' input) and pass the pdf to a pdf reader (zathura).  The problem is that (as you can see in the video) the pdf reader starts even before I select one manpage in dmenu.  And if I click Esc and select none, the pdf reader is still open showing no document at all.  How can I make the pdf reader (and any other command in a pipe chain) to only run when its input reach a end-of-file or when it receives an input at all? Or, alternatively, how can I make a pipe chain to stop after one of the chained commands returns a non-zero exit status (so that if dmenu returns an error for not selecting an option, the following commands are not run)?
97345
One of the applications I use at work sometimes screws with my bash and so I don't see my own input anymore. I.e.  $ echo foo foo $   becomes  $ foo $   I incorrectly tried to run stty -echo which made matters worse and now it stopps accepting commands all together  which put my input in some state that just causes &gt; to appear every time I line break and nothing else.  What should I have done?
109892
I wrote a simple script which echo-es its PID:  #/bin/bash  while true; do     echo $$;     sleep 0.5; done   I'm running said script (it says 3844 over and over) in one terminal and trying to tail the file descriptor in another one:  $ tail -f /proc/3844/fd/1   It doesn't print anything to the screen and hangs until ^c. Why?  Also, all of the STD file descriptors (IN/OUT/ERR) link to the same pts:  $ ls -l /proc/3844/fd/ total 0 lrwx------ 1 mg mg 64 sie 29 13:42 0 -&gt; /dev/pts/14 lrwx------ 1 mg mg 64 sie 29 13:42 1 -&gt; /dev/pts/14 lrwx------ 1 mg mg 64 sie 29 13:42 2 -&gt; /dev/pts/14 lr-x------ 1 mg mg 64 sie 29 13:42 254 -&gt; /home/user/test.sh lrwx------ 1 mg mg 64 sie 29 13:42 255 -&gt; /dev/pts/14   Is this normal?  Running Ubuntu GNOME 14.04.  If you think this question belongs to SO or SU instead of UL, do tell.
54085
I have explored almost    , to no avail.  Let me describe the problem in detail:  I run some unattended scripts and these can produce standard output and standard error lines, I want to capture them in their precise order as displayed by a terminal emulator and then add a prefix like "STDERR: " and "STDOUT: " to them.  I have tried using pipes and even epoll-based approach on them, to no avail. I think solution is in pty usage, although I am no master at that. I have also peeked into the source code of , but that has not been much productive.   Ideally I would use  instead of Bash to accomplish this, but I have not been able to. Seems like pipes automatically forbid keeping a correct lines order because of buffering.  Has somebody been able to do something similar? Or it is just impossible? I think that if a terminal emulator can do it, then it's not - maybe by creating a small C program handling the PTY(s) differently?  Ideally I would use asynchronous input to read these 2 streams (STDOUT and STDERR) and then re-print them second my needs, but order of input is crucial!  NOTE: I am aware of  but it does not work for me with Bash scripts and cannot be easily edited to add a prefix (since it basically wraps plenty of syscalls).  Update: added below two gists       (sub-second random delays can be added in the sample script I provided for a proof of consistent results)  Update: solution to this question would also solve , as @Gilles pointed out. However I have come to the conclusion that it's not possible to do what asked here and there. When using 2&gt;&amp;1 both streams are correctly merged at the pty/pipe level, but to use the streams separately and in correct order one should indeed use the approach of  that involves syscall hooking and can be seen as dirty in many ways.  I will be eager to update this question if somebody can disprove the above.
9691
Hi guys, how do I copy FAR-Manager's console output? For example when I use ping command I want to copy it's output text, but not image.  Oh, and I would like to do so with keyboard! :)
77608
I used one of the following  echo $(stuff) echo `stuff`   (where stuff is e.g. pwd or date or something more complicated).  Then I was told this syntax is wrong, a bad practice, non-elegant, excessive, redundant, overly complicated, a cargo cult programming, noobish, naive etc.  But the command does work, so what exactly is wrong with it?
109523
When I login to console, e.g tty1, I usually see a message No mail, I know there's some program checking email on login, but I don't use that, how can I disable that command ?  I tried to grep from /etc/profile.* and ~/.bash*, but nothing found
102755
I'd like to know if it's possible to send some to a command's stdin and then keep reading from the terminal.  The problem i'm trying to solve is executing some initialization code every time i open a Node.js REPL, so i have some functions available at the REPL from the start. Basically, to automate this:  $ node &gt; require('./myutils') &gt; ... continue using the REPL   I now i can use here string to send some text to the command's stdin:  $ node &lt;&lt;&lt;"require('./myutils')"   That will execute my initialization code, but will also close the REPL immediately after that.  Maybe there's another solution for this particular problem with Node.js, but i'd look to know if there's a general way of mixing input from a string or file and then keep reading from the terminal.  Update:  work, but the Node.js REPL won't run in the interactive mode by default (this is expected, as we're not reading from a terminal). Luckily, there's an -i option to force the interactive mode in the Node.js terminal:  { echo "require('./myutils')" ; cat ; } | node -i
113339
I'm new to Mac usage.  It seems that most commands trip over options given after the file names. In linux, which I've used for years, it doesn't matter.  On Apple, it does.  Is there some setting somewhere or some hack to make commands like ls behave "normal"?  dwilson 0====&gt; ls -l p* -rw-r--r--@ 1 dwilson  owner  184 Jul 29 13:57 poo.c -rw-r--r--@ 1 dwilson  owner  133 Jul 29 13:57 poo.h  dwilson 0====&gt; ls p* -l ls: -l: No such file or directory poo.c        poo.h  dwilson 1====&gt;