A simple Python script to demonstrate running an external program and displaying the output:
# More fun with system calls
# Author: Jeremy Pierson
from subprocess import PIPE, Popen, STDOUT
IP = ‘184.108.40.206’
count = ‘8’
# The section below is the external system call. Parameters are passed as a list,
# which is why they are enclosed in brackets  and seperated by commas. This is very helpful as
# it allows you to easily use seperate variables for different parameters.
# The command below executes ping -c 8 220.127.116.11
p = Popen([‘ping’,’-c ‘+count, IP], stdout=PIPE, stderr=STDOUT)
# -c specifies the number of pings on a Linux system, on windows it’s -n (default is 4 on windows)
# linux boxes will ping indefinitely
#Since the process runs silently until there is output, this message lets you know it is running
#This message displays the output of the command.
This really isn’t much more useful than running a ping directly unless you start to consider how many different ways you can use the output. The output is stored as a variable, so it can be logged, searched, sorted, truncated, concatenated, emailed, posted on a web page, etc. etc.