def bash(*args): """Execute in a bash shell. There are two ways to call this, first as just 'bash' this executes the text and prints the output. Secondly, bash("varname"), executes the text and sets varname equal to this output. """ if (len(args)==3): a,b,c = args ss = b % _getNamespace(2) print ss pp = File.createTempFile("field_tmpBash", "").getAbsolutePath() f = file(pp, "w") print >> f, ss f.close() ex = ExecuteCommand(".", ["/bin/bash", pp], 1) ex.waitFor(1) print ex.getOutput() return ex.getOutput() else: def doBash(a,b,c): ss = b % _getNamespace(2) pp = File.createTempFile("field_tmpBash", "").getAbsolutePath() f = file(pp, "w") print >> f, ss f.close() ex = ExecuteCommand(".", ["/bin/bash", pp], 1) ex.waitFor(1) c[args[0]]=ex.getOutput() return ex.getOutput() return doBash
def bash(*args): """Execute in a bash shell. There are two ways to call this, first as just 'bash' this executes the text and prints the output. Secondly, bash("varname"), executes the text and sets varname equal to this output. """ if (len(args) == 3): a, b, c = args ss = b % _getNamespace(2) print ss pp = File.createTempFile("field_tmpBash", "").getAbsolutePath() f = file(pp, "w") print >> f, ss f.close() ex = ExecuteCommand(".", ["/bin/bash", pp], 1) ex.waitFor(1) print ex.getOutput() return ex.getOutput() else: def doBash(a, b, c): ss = b % _getNamespace(2) pp = File.createTempFile("field_tmpBash", "").getAbsolutePath() f = file(pp, "w") print >> f, ss f.close() ex = ExecuteCommand(".", ["/bin/bash", pp], 1) ex.waitFor(1) c[args[0]] = ex.getOutput() return ex.getOutput() return doBash
def rawPython(a,b,c): """Execute the text as a new CPython process""" tmpFile = File.createTempFile("fieldRawPython", ".py", None) writer = BufferedWriter(FileWriter(tmpFile)) writer.write(b, 0, len(b)) writer.close() com = ExecuteCommand(".", ("/System/Library/Frameworks/Python.framework/Versions/Current/bin/python", tmpFile.getAbsolutePath()),1) com.waitFor(1) print com.getOutput()
def doBash(a,b,c): ss = b % _getNamespace(2) pp = File.createTempFile("field_tmpBash", "").getAbsolutePath() f = file(pp, "w") print >> f, ss f.close() ex = ExecuteCommand(".", ["/bin/bash", pp], 1) ex.waitFor(1) c[args[0]]=ex.getOutput() return ex.getOutput()
def doBash(a, b, c): ss = b % _getNamespace(2) pp = File.createTempFile("field_tmpBash", "").getAbsolutePath() f = file(pp, "w") print >> f, ss f.close() ex = ExecuteCommand(".", ["/bin/bash", pp], 1) ex.waitFor(1) c[args[0]] = ex.getOutput() return ex.getOutput()
def rawPython(a, b, c): """Execute the text as a new CPython process""" tmpFile = File.createTempFile("fieldRawPython", ".py", None) writer = BufferedWriter(FileWriter(tmpFile)) writer.write(b, 0, len(b)) writer.close() com = ExecuteCommand(".", ( "/System/Library/Frameworks/Python.framework/Versions/Current/bin/python", tmpFile.getAbsolutePath()), 1) com.waitFor(1) print com.getOutput()