/bin/sh: rm: command not found I have problems with some applications that use AppleScript shell script feature. For example, Growl's uninstall scripts shows an error:

error "/bin/sh: rm: command not found" number 127


The source of the script is

display dialog (localized string "title")
if button returned of result = "OK" then
    try
        quit application id "com.Growl.GrowlHelperApp"
    end try
    try
        quit application id "com.Growl.MenuExtra"
    end try
    do shell script "rm -rf /Library/PreferencePanes/Growl.prefPane ~/Library/PreferencePanes/Growl.prefPane" with administrator privileges
    display dialog (localized string "succeeded") buttons {localized string "OK"} default button 1
end if


I've added echo $PATH &gt; /omg.txt &amp;&amp; to the command to see what's the search path for rm. But it has a weird value:

$ cat /omg.txt 
â


What can I do? I don't understand what's going on. When I just run sudo /bin/sh in Terminal, the environment is just fine!

Now, I know that to uninstall Growl I can just run the command it tries to run in the Terminal. But it won't solve this problem, just postpone it until another application fails with the same error (it happened before).
According to Apple's official documentation, it is by design that shell scripts invoked from AppleScript's do shell script action do not inherit the $PATH variable from your login shell's environment. 

Accordingly, Apple instructs users to use full paths to commands when invoking shell scripts from AppleScript rather than relying on the $PATH variable in the environment.

In the script in your example, you could replace rm with /bin/rm

According to the aforelinked documentation, this is the intended, documented behavior; a script that expects the environment's $PATH to be set for do shell script commands is a script with a bug.

That said, if you absolutely need to use relative paths and use $PATH to complete them, you could prefix any shell script called by do shell script with the command PATH=/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/bin;