I've been curious ever since I've started bash scripting in Ubuntu, and I have been wondering if there was a way to log in as root or run a sudo command without physically typing the password manually when it prompts you in the terminal.
Is it possible to hard-code the password into a line, such as "echo mypassword" and have sudo read through the echo command instead of typing for myself?
I've looked around that you could, if you had set the root to have no password, which is something I do not want.
I've just been playing around with bash and seeing if I could login as root and run a command in root through the bash script only:
#!/bin/bash echo mypassword | sudo apt-get install frozen-bubble
This is just out of my pure curiosity, and was just wondering how to implement it if it was possible. Thanks.
IF this is relevant, I'm using Ubuntu 9.04.