Need assistance while i want to ping server if got reply then proceed with script and if no reply go again to previous step where we fetch IP from hosts.txt
#Setting up Variables
set timeout 5
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"}
}