Skip to main content

I have a need a lot of times to execute sudo wrapped commands in shell scripts that I use for automating tedious tasks, like installing OIM =).

The kicker is that sometimes, I need to run commands as root. Here’s the quick and dirty way I accomplish that without divulging the passwords:

#! /bin/bashread -s -p “Enter Password for sudo: ” sudoPWecho $sudoPW | sudo -S yum update

This way the user is prompted for the password (and hidden from terminal) and then passed into commands as needed, so I’m not running the entire script as root =)

If you have a better, way, I’d love to hear it! I’m not a shell scripting expert by any means.

Cheers!