How can I login to another account in bash script with password?
I try such command:
su - test
expect "password: "
send "$pass"
But it doesn't work
Use something along the lines of
#!/usr/bin/expect
set USER test
set PASS password_of_test
spawn su - $USER
expect "*assword:"
send $PASS
send "\n"
interact
NOTE
I would strongly suggest that you do not store passwords in plaintext; a much better solution would be to use sudo
to run commands as a different user.