Oh my god! I have tried everything about expect. What I want to do is create a script to automate input password when changing to root in terminal. My code look like this
expect -i
spawn sudo pmset schedule sleep "{query}" expect { Password: send "password\r" }; interact;
exit
result
expect1.1> spawn sudo pmset schedule sleep "06/19/11 23:40:00" expect { Password: echo "lovegun\r" }; interact; exit
spawn sudo pmset schedule sleep 06/19/11 23:40:00 expect Password: send "password\r"
Password:
I am stuck in password: Can somebody look at my code? What is wrong with this.
expect -c '
proc abort {} {
puts "You have Authenticated\n"
exit 1
}
spawn sudo pmset schedule sleep "{query}"
expect {
Password: { send "password\n" }
default abort
}
puts "Finished OK\n"
'
Finally I found the answer