shown previouslyc:\pp \systempython import os os system('dir / 'helloshell py more py more pyc spam txt __init__ py os system('type helloshell py' python program print('the meaning of life' os system('type hellshell py'the system cannot find the file specified the at the end of the first two commands here are just the return values of the system call itself (its exit statuszero generally means successthe system call can be used to run any command line that we could type at the shell' prompt (herec:\pp \system>the command' output normally shows up in the python session' or program' standard output stream communicating with shell commands but what if we want to grab command' output within scriptthe os system call simply runs shell command linebut os popen also connects to the standard input or output streams of the commandwe get back file-like object connected to the command' output by default (if we pass mode flag to popenwe connect to the command' input stream insteadby using this object to read the output of command spawned with popenwe can intercept the text that would normally appear in the console window where command line is typedopen('helloshell py'read(" python program\nprint('the meaning of life')\ntext os popen('type helloshell py'read(text " python program\nprint('the meaning of life')\nlisting os popen('dir / 'readlines(listing ['helloshell py\ ''more py\ ''more pyc\ ''spam txt\ ''__init__ py\ 'herewe first fetch file' content the usual way (using python files)then as the output of shell type command reading the output of dir command lets us get listing of files in directory that we can then process in loop we'll learn other ways to obtain such list in there we'll also learn how file iterators make the readlines call system tools