[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: root can't sudo



>> On Tue, 28 Sep 2010 09:42:40 -0400 (EDT), 
>> Stephen Powell <zlinuxman@wowway.com> said:

S> I don't speak for the OP, but my guess is that the OP has a script that
S> he wants to be able to run either as his non-superuser self or as root.

   Easy.  This preserves arguments including spaces:

     #!/bin/sh
     PATH=/usr/local/bin:/bin:/usr/bin; export PATH
     test "`id -u`" -gt 0 && exec sudo $0 "$@"

     whoami
     for arg in "$@"; do
         echo "[$arg]"
     done
     exit 0

-- 
Karl Vogel                      I don't speak for the USAF or my company

EXCUSE FOR GETTING TO WORK LATE #7:
The dog ate my car keys.  We're going to hitchhike to the vet.


Reply to: