I have created a Python script which calls an R script and then reads the output back into Python. I can run this tool in ArcGIS Desktop (10.2.1) and it works fine. When I publish as a geoprocessing service it fails once it reaches the R script. I have checked the file paths and they are fine. Is it even possible to call external scripts from a geoprocessing service? Here is my code.
import sys, os, arcpy arcpy.AddMessage("Loaded Python Imports...") try: #User Input lat = arcpy.GetParameterAsText(0) long = arcpy.GetParameterAsText(1) arcpy.AddMessage("LAT: " + "".join(lat)) arcpy.AddMessage("LONG: " + "".join(long)) #Create R Command rScript = "test.R" args = " ".join([lat, long]) RCMD = "R --slave --vanilla --args " cmd = RCMD + args + " < " + rScript #Execute os.system(cmd) #Render the Results output = open("FILE PATH") finalNumber = output.read() print("The output is: " + " ".join(finalNumber)) arcpy.AddMessage("The output is: " + " ".join(finalNumber)) output.close() #Delete Text File os.remove("FILE PATH") except Exception as e: print e.message arcpy.AddError(e.message)