Using the the sudo command in a shell script
File: macportsUpdate.sh
# This a simple bash script outlining the procedures to get macports on OS X
# to auto update weekly via the ~/Library/LaunchAgents/net.ipatch.macportsUpdate.plist
# The first step is to update the port files
echo "Step 1: Update port tree"
sudo port selfupdate
# The second step is to upgrade the outdated
echo "Step 2: Upgrade outdated"
sudo port upgrade outdated
# The third step is to remove inactive ports
echo "Step 3: Remove inactive ports"
sudo port uninstall inactive
# The fourth step is to clean the vile
echo "Step 4: Clean the vile"
sudo port clean --all vile
My question is how to get the script to run through the four steps without having me in front of the computer to enter a password after the several hours it takes to run the first step because terminal/shell prompts me for a password because it takes several minutes/hours to run the first step so the sudo password is required to run steps 2 -4.
PS sorry for my lack of formatting/markup, I thought this forum used UBB code for markup but apparently I am mistaken. Well, I found the formatting thread, here 😀
Macbook pro, Mac OS X (10.6.5), Santa Rosa