Python programs from command line


When you write


in command line it executes
My question is how can I do this from python shell/a preloaded python program. I’ve done some digging on the internet and I’ve found a few ways to do this, but none of them actually print out the results.

Some, like subprocess.check_output(command) and commands.getoutput(command) can print out when you use the ls command but do not work with the python command. Others like os.Popen(command).readlines(), and os.system(command) print 0 or ‘’ meaning the program worked but without actaully printing it out or making the gopigo move.

I’m currently trying to python which is a data packet in the groove GPS sensor. When I access the packet on command it prints the GPS coordinates. This is what I’m currently trying to do in python but I can’t execute any other program. I’ve been able to spit out the beginning of user input in one of my programs by using commands.get output
(in python 2.7) but not execute the actual program.

I have, however, been able to change libraries by using os.chdir(path) and os.getcwd prints the current directory. I can navigate but not execute specific programs.

I just want to write print (command) and print out some GPS coordinates. Any help is appriciated.