Or here's a simpler, if less pretty, way of doing that taken from the Sweave manual: echo "library(\"utils\"); Sweave(\"$TM_FILEPATH\")" | R --no-save -- no-restore I prefer all the nice HTML you get from using tmR.rb though.