Modified shell R file as instructed. Tested and appears to function properly.