#!/usr/bin/expect
set IP [ lindex $argv 0 ]
set PASS [ lindex $argv 1 ]
set COMMAND [ lindex $argv 2 ]
spawn ssh root@$IP $COMMAND
expect {
"yes/no" {send "yes\r";exp_continue}
"password:" {send "$PASS\r"}
}
interact
set IP [ lindex $argv 0 ]
set PASS [ lindex $argv 1 ]
set COMMAND [ lindex $argv 2 ]
spawn ssh root@$IP $COMMAND
expect {
"yes/no" {send "yes\r";exp_continue}
"password:" {send "$PASS\r"}
}
interact
#!/bin/bash
if [ -n "$*" ]
then
MAX_LINE=`wc -l $* | awk '{print $1}'`
for NUM in `seq 1 $MAX_LINE`
do
IP=`sed -n ${NUM}p $* | awk '{print $1}'`
PASS=`sed -n ${NUM}p $* | awk '{print $2}'`
echo ${IP}\'s hostname is `/mnt/ssh.exp $IP $PASS hostname | tail -n 1`
done
else
echo "Useage:ssh.sh <filename>"
fi