Root User login by shell Scripts
Create a shell file with the name of rootpass.sh and add below codes, then give execute permission to that file.
Set root password directly in shell script, assume that the root password is: rpasswd
spawn sudo -s <<EOF
send -- "rpasswd\r"
If you want to pass arguments(root password)create a file name rootpass.sh and add below code in it.
set rpasswd [lindex $argv 0]
spawn su - root
I hope, the above scripts is functional.