Personally I do quite the same as John T answered on Nov 9 '09 at 2:47, I've also improved mine according to guidance of his answer, thanks.
Difference is that I tend make use of variables, something like:
AutoSuDo=$" $echo pass | sudo -S";
# Change AutoSuDo to something else.
# Note that string starts with space,
# useful only if used as first command in line
In that way I can easily use mine variable instead of sudo,
$AutoSuDo apt-get update;
That comes quite handy with some longer scripts. I mainly make use of these for personal computers of others, that I have to maintain.
I also recommend to pay attention on:
- desgua answer on Apr 19 '11 at 23:56
- user224306 comment on May 14 '13 at 17:38 for John T answer on Nov 9 '09 at 2:47