From: J L. T. <jlt...@ma...> - 2023-08-04 04:47:08
|
Well. A suggestion by Rony Flatscher found a solution to this issue. It seems that stty, unless told otherwise, does not use the most usual method of writing to the terminal, but it can be told to do so, using the --file=<device> flag, where <device> can be any "real" tty owned by the issuer of the stty command; so one can use the w command to see what ttys are available: | $ w | grep leslie | Cyllarus pts/15 :0 Mon02 3days 0.00s 0.00s su - leslie | leslie pts/33 :1 Mon12 4.00s 5:34 0.00s grep --color=auto leslie | leslie pts/34 :1 Mon12 28:53 6:09 0.02s su - | leslie pts/36 :1 Mon12 3days 0.03s 0.03s /bin/bash | leslie pts/35 :1 Mon12 2days 0.09s 0.09s /bin/bash | leslie pts/37 :1 Mon12 3days 0.03s 0.03s /bin/bash | leslie pts/38 :1 Mon12 3days 0.03s 0.03s /bin/bash | leslie pts/39 :1 Mon12 3days 0.03s 0.03s /bin/bash | leslie pts/40 :1 Mon12 2days 0.07s 0.02s su - | leslie pts/41 :1 Mon12 2days 0.07s 0.02s su - | leslie pts/42 :1 Mon12 2days 2.35s 0.01s /usr/bin/links file:///usr/share/doc/fish/index.html | leslie pts/43 :1 Mon12 3days 0.03s 0.03s /bin/bash | leslie pts/44 :1 Mon12 3days 0.00s 2:33 kded [tdeinit] --new-startup | leslie pts/45 :1 Tue16 2days 2.13s 2.13s /usr/bin/fish | developm pts/52 :2 Tue22 2days 0.00s 0.00s su - leslie | rc=0 | | $ stty --file=/dev/pts/45 --all | speed 38400 baud; rows 54; columns 135; line = 0; | intr = ^C; quit = <undef>; erase = ^?; kill = ^U; eof = ^D; eol = <undef>; eol2 = <undef>; swtch = <undef>; start = ^Q; | stop = ^S; susp = <undef>; rprnt = ^R; werase = ^W; lnext = ^V; discard = ^O; min = 1; time = 0; | -parenb -parodd -cmspar cs8 -hupcl -cstopb cread -clocal -crtscts | -ignbrk -brkint -ignpar -parmrk -inpck -istrip -inlcr -igncr -icrnl -ixon -ixoff -iuclc -ixany -imaxbel iutf8 | opost -olcuc -ocrnl onlcr -onocr -onlret -ofill -ofdel nl0 cr0 tab0 bs0 vt0 ff0 | isig -icanon -iexten -echo echoe echok -echonl -noflsh -xcase -tostop -echoprt echoctl echoke -flusho -extproc | | rc=0 Interestingly, any tty device owned by the user can be specified; stty writes its output to the tty where the command is invoked, not the one specified by the --file= option. I used the console feature of the jEdit text editor, which is implemented in Java, to verify that this works, and that the following pipeline, more compact than the bash script I used to use, works as well: | $ pipe 'command stty --all --file=/dev/pts/33|take first 1|specs word 5 next|strip trailing /;/|console' | 54 | rc=0 Leslie On 2023-07-31 09:27:09 Marc Remes wrote: > Leslie, > > pipe 'command stty --all|console also runs fine.. Its output is empty > because it is not connected to a real/pseudo terminal, as echo dog |tty > reports. > > Indeed, we're not doing bash redirection, it is now java that is doing the > redirection. The command stage starts the stty process by r.exec and > connects to its stdin. For the stty process there's no difference whether > the redirection is done by bash or java, in both cases its stdin is not a > terminal. And thus stty has no effect. > > Marc > > On 7/31/23 16:00, J Leslie Turriff wrote: > > On 2023-07-31 06:20:50 Marc Remes wrote: > >> On 7/31/23 13:03, Rony G. Flatscher wrote: > >>> According to "https://linux.die.net/man/1/stty" "stty --all" would > >>> print all settings (to stdout I assume). > >> > >> True : > >> > >> $ stty --all > >> speed 38400 baud; rows 30; columns 99; line = 0; > >> intr = ^C; quit = ^\; erase = ^?; kill = ^U; eof = ^D; eol = <undef>; > >> eol2 = <undef>; swtch = <undef>; start = ^Q; stop = ^S; susp = ^Z; rprnt > >> = ^R; werase = ^W; lnext = ^V; discard = ^O; min = 1; time = 0; > >> -parenb -parodd -cmspar cs8 -hupcl -cstopb cread -clocal -crtscts > >> -ignbrk -brkint -ignpar -parmrk -inpck -istrip -inlcr -igncr icrnl ixon > >> -ixoff -iuclc -ixany -imaxbel iutf8 > >> opost -olcuc -ocrnl onlcr -onocr -onlret -ofill -ofdel nl0 cr0 tab0 bs0 > >> vt0 ff0 isig icanon iexten echo echoe echok -echonl -noflsh -xcase > >> -tostop -echoprt echoctl echoke -flusho -extproc > >> $ echo dog | stty > >> stty: 'standard input': Inappropriate ioctl for device > >> > >> The first command is attached to a terminal (either a 'real' terminal, > >> but more likely a pseudo-terminal), and shows its settings. The second > >> command's stdin is the stdout of the echo command, and says so.. > >> > >> Also check the tty command: > >> $ tty > >> /dev/pts/6 > >> $ echo dog | tty > >> not a tty > >> > >> Marc > > > > But: > > | @08:49:08 ─▶leslie@pinto◀─ > > | wd=~/bin/NetRexx/Pipelines > > | $ pipe 'command ls -l|console' > > | total 224 > > | -rw-r--r-- 1 leslie users 3741 Jun 29 01:44 condense.class > > | -rw-r--r-- 1 leslie users 1298 Jun 29 00:07 GenSymLinks.class > > | -rw-r--r-- 1 leslie users 4688 Jun 28 23:53 > > | GenSymLinks_gensymlinks.class > > | > > | -rw-r--r-- 1 leslie users 2403 Jun 19 15:50 treeOutput.txt > > | rc=0 > > > > works just fine, whereas > > > > | @08:49:20 ─▶leslie@pinto◀─ > > | wd=~/bin/NetRexx/Pipelines > > | $ pipe 'command stty --all|console' > > | rc=0 > > > > produces no output. What is the difference between the stage "command ls > > -l" (which works) and "command stty --all" (which does not)? We're not > > doing bash redirection here; this is inside the NetRexx pipeline. > > > > Leslie > > _______________________________________________ > netrexx-pipelines mailing list > net...@li... > https://lists.sourceforge.net/lists/listinfo/netrexx-pipelines |