Upload from command line

If I have a sketch compiled to hex, shouldn't it be possible to upload it to Arduino board using avrdude directly from command line? I figured out that arduino ide executes the following command when uploading the sketch:

hardware/tools/avrdude -Chardware/tools/avrdude.conf -pm328p -cstk500v1 -P/dev/ttyUSB0 -b57600 -D -Uflash:w:/home/pekka/sketchbook/Blink2/applet/Blink2.hex

But when I try to run it from command line, I got an error message:
avrdude: stk500_getsync(): not in sync: resp=0xe0
avrdude: stk500_disable(): protocol error, expect=0x14, resp=0xe0

I am obviously missing something here. Does the ide do something in addition of executing avrdude when it uploads the sketch?

I want to do this because I use arduino to control and monitor the heating system of my house. I use ARM-based SheevaPlug minicomputer to interface arduino (configuring and logging). avrdude is available for that platform, but I guess I wouldn't be easy to get full arduino ide running on it. I would like to compile the sketch to hex on my Linux PC, copy the hex to SheevaPlug and then upload it using avrdude.

I guess the problem is that I need to reset the board when uploading. Any idea how I can issue the auto reset (arduino ide does it, right?) when uploading from command line?

Ok, it seems that I found the solution. A simple perl command sends the DTR signal before executing avrdude:

perl -MDevice::SerialPort -e 'Device::SerialPort->new("/dev/ttyUSB0")->pulse_dtr_on(1000)'; \
./hardware/tools/avrdude -Chardware/tools/avrdude.conf -q -q -pm328p -cstk500v1 -P/dev/ttyUSB0 -b57600 -D -Uflash:w:/home/pekka/sketchbook/Blink2/applet/Blink2.hex;

Thank you for posting this! On Mac OSX, with an Arduino Mega, I can see the device (at /dev/tty.usbserial-A7006QAX and /dev/cu.usbserial-A7006QAX (side note - why both, and what is the difference)) but the Arduino software (I'm using 0017) refuses to upload. The workaround that this thread helped me find is to have the IDE attempt to upload, so that it compiles and fails, and then run this command from the project directory:

/Applications/Arduino.app/Contents/Resources/Java/hardware/tools/avr/bin/avrdude -C/Applications/Arduino.app/Contents/Resources/Java/hardware/tools/avr/etc/avrdude.conf -pm1280 -cstk500v1 -P/dev/cu.usbserial-A7006QAX -b57600 -D -Uflash:w:applet/Blink.cpp.hex

Yay I can program the Arduino now!

Durka: what happens if you try to program the board from the IDE? Did you select Arduino Mega from the Tools > Board menu?

Arduino Mega is selected in the Board menu. The Serial Port menu is grayed out. When I click upload, it compiles the program and then says it can't find /dev/cu.usbserial-A7006QAX (which is what I put in the config file to replace COM1). After that I run the above command on the compiled .cpp.hex file and it works.