you would get some of the code on how to do that by following this forum here for arduino
[
www.arduino.cc]
they discuss on how to program another arduino with an arduino. still it is programming flash memory. you probably will want to write the code and reboot the arduino externally somehow. i think there is a way to program a reset, one way is the wdt . good luck!