Errors attempting to run example program

I got an Artuino Duemilanove AT328, and i'm on OS x 10.5.7, when i'm trying to upload the blink example, after i select my serial port (/dev/tty.usbserial-A6008c9d) and select my board, i open the example, press reset on my board wait a while, and then press upload on the Arduino 16 IDE. Afterwhich I get this error:

hardware/tools/avr/bin/avr-g++: line 2: dirname: command not found
hardware/tools/avr/bin/avr-g++: line 2: readlink: command not found
hardware/tools/avr/bin/avr-g++: line 5: dirname: command not found
hardware/tools/avr/bin/avr-g++: line 5: /../avr-4/bin/g++: No such file or directory
hardware/tools/avr/bin/avr-g++: line 5: exec: /../avr-4/bin/g++: cannot execute: No such file or directory
hardware/tools/avr/bin/avr-gcc: line 2: dirname: command not found

hardware/tools/avr/bin/avr-gcc: line 2: readlink: command not found

hardware/tools/avr/bin/avr-gcc: line 5: dirname: command not found

hardware/tools/avr/bin/avr-gcc: line 5: /../avr-4/bin/gcc: No such file or directory

hardware/tools/avr/bin/avr-gcc: line 5: exec: /../avr-4/bin/gcc: cannot execute: No such file or directory

Couldn't determine program size: hardware/tools/avr/bin/avr-size: '/Applications/arduino-0016 17-22-53/examples/Digital/Blink/applet/Blink.hex': No such file

avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_recv(): programmer is not responding

I checked for the files it says that it cannot find, and they are there, i also checked for those commands, and I have them...i'm thinking it may be a permissions problem, but cannot quite pin down how to fix it, it may be completely unrelated to permissions...anyone have any guesses or further troubleshooting tips??

If you type: which dirname at the Terminal, what do you get? Is it /usr/bin/dirname? What about which readlink? Is it /usr/bin/readlink?

If so, you could try adding a line like: PATH=/usr/bin:$PATH as the second line (after the #!/bin/sh line) of the hardware/tools/avr/bin/avr-g++ file (and any others for which you get similar errors). Does that change the errors you get at all?

That worked perfectly, thank!!

It seems i did something to kill some of my exported path variables, now my system cannot seem to find any of the gems i need for my Ruby on Rails processes, do you have a good resource recomendation on where I can read up on OS X and the $PATH variables, i've been using them for some time?

If not, thanks for your help again!!