How can we write a shell script to become root?That is I donot want to input the password at prompt it should be within the script itself. I was trying to make but failed to do so.Is it possible, if Yes please Explain.
Shell script to become root
shell;shell script;password;root;su
You can write a script using expect tool.In Redhat, expect package comes by default. But in Ubuntu you need to install it separately.You can check this by using commands:$ rpm -qa | grep expect     for Redhat$ dpkg -l expect for UbuntuThe following script will do your work: #!/usr/bin/expectspawn su -expect Password: send password\rinteract