I am calling a second python script that is written for the command line from within my script using
os.system('insert command line arguments here')
You can use the subprocess module and redirect its output through a pipe.
For example, to get the list of file in current directory.
import subprocess proc = subprocess.Popen(['ls'], stdout=subprocess.PIPE) print(proc.stdout.readlines())
More details here Redirecting stdio from a command in os.system() in python