import os apache = os.system('/etc/init.d/apache status'); if apache = 1: apache = 1 print 'Online' else: print 'Offline'