Using:
Linux nomemory 2.6.32-24-generic #43-Ubuntu SMP Thu Sep 16 14:17:33 UTC 2010 i686 GNU/Linux
I have a folder in my $HOME called ~/.scriptfarm/scripts where i keep some of my custom scripts.
nomemory@nomemory:~$ ls -l /home/nomemory/.scriptfarm/script
total 20
-rwxr-xr-x 1 nomemory nomemory 10 2010-09-21 01:31 aaa
-rwxr-xr-x 1 nomemory nomemory 31 2010-09-21 00:47 pt.chc
-rwxr-xr-x 1 nomemory nomemory 35 2010-09-21 00:47 pt.int
-rwxr-xr-x 1 nomemory nomemory 34 2010-09-21 00:47 pt.rem
-rwxr-xr-x 1 nomemory nomemory 54 2010-09-21 00:47 pt.up
The problem is that in Ubuntu none of the scripts are working when prefixed with sudo. The behavior is different on Arch, where the scripts are working.
Let me give you an example (aaa is a foobar-type script):
nomemory@nomemory:~$ aaa
aaa
nomemory@nomemory:~$ sudo aaa
sudo: aaa: command not found
nomemory@nomemory:~$
And if a echo $PATH:
nomemory@nomemory:~$ sudo echo $PATH
/home/nomemory/.scriptfarm/script:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games
Do you know why my scripts don't work if I prefix them with sudo.
Any solutions ?
Later edit:
The work-around I found was to add an alias for sudo: sudo env PATH=$PATH $@ .