So, if code.R
is a script that has to be interpreted you must build the pipe to the interpreter not to the script. You receive a Broken PIPE
error because code.R
by it self don't know how to handle command line arguments.
On the other hand if what you want is store the variable
value inside code.R you have to change |
by >>
.
os.system("cat " + variablename + ">> code.R")
EDIT: Since it's working from terminal, try this:
import subprocess
input = open(variableName, "r")
result = suprocess.call(["code.R"], stdin=input) # result is the return code for the command being called.
see subprocess.call for more details.