-
Notifications
You must be signed in to change notification settings - Fork 1.8k
SC2095
koalaman edited this page Jan 20, 2018
·
8 revisions
The same error applies to multiple commands, like ffmpeg
and mplayer
.
while read -r host
do
ssh "$host" "uptime"
done < hosts.txt
while read -r host
do
ssh "$host" "uptime" < /dev/null
done < hosts.txt
Commands that process stdin will compete with the read
statement for input. This is especially tricky for commands you wouldn't expect reads from stdin, like ssh .. uptime
, ffmpeg
and mplayer
.
The most common symptom of this is a while read
loop only running once, even though the input contains many lines. This is because the rest of the lines are swallowed by the offending command.
To refuse such commands input, redirect their stdin with < /dev/null
.
You can also use command specific options like ssh -n
and mplayer -noconsolecontrols
.
None.