expectコマンド
#!/bin/sh
while read HENSU
do
expect -c "
set timeout 10
spawn ssh kenken@$HENSU
expect \"s password:\"
send \"kenken\n\"
expect \"~]\"
send \"su -\n\"
expect \"パスワード:\"
send \"kenken\n\"
send \"sh /home/kenken/script\n\"
expect \"OK\"
expect \"~]\"
"
done<aaa.txt
※ちなみにscriptにはapacheの起動と停止を
/etc/init.d/httpd start
/etc/init.d/httpd stop
のOKをexpectしております。