URL: https://linuxfr.org/forums/programmation-shell/posts/d%C3%A9tecter-des-pipes-%C3%A0-travers-ssh Title: Détecter des pipes à travers ssh. Authors: Anthony Jaguenaud Date: 2011年11月09日T10:56:18+01:00 Tags: Score: 1 Bonjour, J’ai écris ceci pour détecter si mon script est utilisé dans un terminal ou via un pipe. ```bash #!/bin/bash echo -n "STDIN: "; [ -t 0 ] && echo TERM || echo PIPE echo -n "STDOUT:: "; [ -t 1 ] && echo TERM || echo PIPE echo -n "STDERR: "; [ -t 2 ] && echo TERM || echo PIPE ``` Utilisation en local : ```bash $ ./term.sh STDIN: TERM STDOUT:: TERM STDERR: TERM $ echo toto | ./term.sh STDIN: PIPE STDOUT:: TERM STDERR: TERM $ ./term.sh | grep STD STDIN: TERM STDOUT:: PIPE STDERR: TERM $ ``` Via ssh : ```bash $ ssh localhost ./term.sh login@localhost password: ################## # BASHRC running # ################## STDIN: PIPE STDOUT:: PIPE STDERR: PIPE $ ssh -t localhost ./term.sh login@localhost password: ################## # BASHRC running # ################## STDIN: TERM STDOUT:: TERM STDERR: TERM Connection to localhost closed. $ echo toto | ssh -t localhost ./term.sh login@localhost password: ################## # BASHRC running # ################## STDIN: PIPE STDOUT:: PIPE STDERR: PIPE $ ``` Donc question, comment dire à ssh de laisser les terminaux comme il les trouve ? J’ai cherché du côté de tput, mais je n’ai rien trouvé de valable :'( Question subsidiaire, comment empêcher l’exécution du bash(rc|_login) ?

AltStyle によって変換されたページ (->オリジナル) /