Sorry for the bad way of posting code and variables. It works perfect, faster than the usual for,for for loops Listofitems3 = įor command in ("Rscript script.R -args %s %s %s" % (one, two, three) Without that module you seem to like something like (I have not R so I have commented out it, and as you give no value for the variables I changed them to string to check the correctness): listofitems = Maybe you should check Learning R via Python. Also it is better to build directly list than have variables like a1,s1 etc. as an example: /usr/bin/python import subprocess commandls -l dibnerscum.py commands command, dibner subprocess. Tried a couple of ways but it only ever seems to run the first section. Looks like it makes no sense for me script gets parameter 'args' fro example which even has no meaning in the python side and treats it as string. This is basically just like the Popen class and takes all of the same arguments, but it simply wait until the command completes and gives us the return code. learning python to replace bash here and Ive tried to generate an argument and pass it to subprocess.call. You should not need to use string formatting where you have 's' url. You can also specify shellTrue and give the whole command as a single string, but this is not recommended due to potential security vulnerabilities. Makes more sense at least if you remember to push that (code) button before pasting. Each argument needs to be separated when subprocess.call is used with shellFalse (the default). So that it can take each item from each list and iterate over it. Subprocess.call("Rscript script.R -args arg1 arg2", shell=True)