您好,登錄后才能下訂單哦!
exp文件的編寫
#!/usr/bin/expect
set timeout 10
set fname [lindex $argv 0]
set ip [lindex $argv 1]
set dname [lindex $argv 2]
#spawn scp $fname root@$ip:$dname
spawn ssh root@$ip
expect {
"*yes/no*" { send "yes\n";exp_continue}
"*password*" { send "aixocm\n";exp_continue}
}
expect "*#*" {send "cd /tmp\n"}
expect "*#*" {send "mkdir /tmp/zlj\n"}
expect "*#" {send "exit\n"}
expect eof
.sh文件的編寫
#!/bin/bash
#
#nmap -n -sT -p22 10.0.10.1-253|egrep -o '10.0.10.[0-9]{1,3}' >ip.txt
#nmap -n -sT -p22 10.0.10.1-253|egrep "22/tcp" |awk '{print $2}' >statu.txt
statu=(`cat statu.txt`)
fname=/root/shell/7_1.sh
dname=/tmp
count=0
while read ip
do
if [ "${statu[$count]}" == "open" ];then
./expect1.exp $fname $ip $dname
fi
((count++))
done < ip.txt
如果.sh文件運行時,提示 spawn:command not found
則給.sh文件添加x權限,使用./x.sh的樣式運行
免責聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點不代表本網(wǎng)站立場,如果涉及侵權請聯(lián)系站長郵箱:is@yisu.com進行舉報,并提供相關證據(jù),一經(jīng)查實,將立刻刪除涉嫌侵權內(nèi)容。