ファイルがあり、このファイルには次の行があります。
ssh [email protected]
ssh [email protected]
etc....
各サーバーで実行し、そのファイル内の各サーバーでlsコマンドを実行したいスクリプトがあります。私が今やっていることは:
while read line;
do
$line
done < $1
うまくいきますが、最初の行についてはそれ以降
stdin が端末ではないため、疑似端末は割り当てられません。間違い。
だから私は何かを見逃していることを知っていますが、ここでは少し迷子になりました。
ベストアンサー1
ファイルにコマンドオプションを追加します-t
。ssh
ssh -t [email protected]
ssh -t [email protected]
etc....
からman ssh
:
-t Force pseudo-tty allocation. This can be used to execute arbi‐
trary screen-based programs on a remote machine, which can be
very useful, e.g. when implementing menu services. Multiple -t
options force tty allocation, even if ssh has no local tty.
それでもエラーが発生する場合は、次-t
のオプションを追加してください。
ssh -t -t [email protected]