sshやscpなど、対話型のインプットが必要なコマンドを、スクリプト化して運用に使いづらいので、expectパッケージを利用すると便利です。 OSにあらかじめexpectのパッケージが入っていない場合、下記コマンドでインストール。 yum install expect下記は、リモートホストにログインして ls を叩くシェルのサンプルです。 #!/bin/bash hostname=192.168.10.12 username=hoge password=hogehoge expect -c " spawn ssh -l oracle $hostname expect \"$username@$hostname's password:\" { send \"$password\n\" } \"Are you sure you want to continue connecting (yes/
![expectで対話型シェル - MB blog](https://cdn-ak-scissors.b.st-hatena.com/image/square/06a15c64ba0ceec233d86d71001ebb29a9dcbf5d/height=288;version=1;width=512/https%3A%2F%2Fcdn.blog.st-hatena.com%2Fimages%2Ftheme%2Fog-image-1500.png)