I want to write a shell script that can login to root user and it should carry password inside the same script. It should not ask for password on the terminal.
I have written a script that works fine, but it is asking for password on the terminal, I want to automate this process by giving the password inside script only.
id
sudo -s <<EOF
echo Now i am root
id
mkdir someDir
whoami
EOF
note: i want to get it done without touching /etc/sudoers file.
expect
for thatexpect
like thisspawn ./c.sh expect "[sudo] password for divyaa:\r" send -- "mypass\r" expect eof
but its giving this errorspawn ./c.sh invalid command name "sudo" while executing "sudo" invoked from within "expect "[sudo] password for divyas:\r"" (file "./a.sh" line 7)