for below code i want to check if the IP is up via ping and if ip is up run below code eles check next ip from hosts.txt
Edit 2: FYI ill be running script from windows machine
Edit 3:I managed to write incorporate a line,now with this script is pinging all the IP's mentioned in hosts.txt file but fails if any IP is down. What is required: I want script to go to the next IP if any IP is down.
#!/usr/bin/expect -f
#This Script will provide critical info which are required during troubleshooting
#Setting up Variables
set timeout 15
set fid [open ./hosts.txt r]
set contents [read -nonewline $fid]
close $fid
#Grabbing Password to be used in script further
stty -echo
send_user -- "Enter the Password: "
expect_user -re "(.*)\n"
send_user "\n"
stty echo
set pass $expect_out(1,string)
foreach host [split $contents "\n"] {
set timeout 5
spawn ping $host
expect {
"Reply" {puts "$host Is Up"}
"Request" {puts "$host Is Down"}
}