Compilation of exp Files
#!/usr/bin/expect
Set Timeout 10
Set fname [lindex $argv 0]
Set IP [lindex $argv 1]
Set dname [lindex $argv 2]
#spawn SCP $fname [email protected] $ip: $dname
Spawn ssh [email protected] $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
Compilation of. sh files
#!/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 $} ' >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
If the. sh file is running, prompt spawn:command not found
Add x permission to the. sh file, run with the./x.sh style
This article is from the "Sunny Rain" blog, please be sure to keep this source http://8776055.blog.51cto.com/8766055/1837223
Expect example _shell script