I have written a script to switch user and do some operations. I used expect command it doesn't work. It switches the user and waits for the Password to be entered manually. Also, i tried to fetch the pasword from passwd file, it didn't work.The script is as below:
#!/usr/local/bin/expect
su - ABC
expect "assword:"
send "password of ABC\r"
expect "\]\"
sleep 5
expect closed
No, when you enclose something in quotes, Expects takes it as literal string, instead, you should use wildcard, as in :
expect "*assword" - with case sensitivity in mind
or just 'expect assword:' without the quotes.