Running a Python program from PHP in the background (Python output on cmd) and displaying the counter in PHP
<p><strong>I need to run a Python script from PHP in the background, and the Python script will output its content to cmd (I need to display cmd) and display a live counter in the PHP file as long as the Python script is running.</strong></p>

<p>I have tried all the exec and system commands, but I am unable to obtain the desired results. Help :)  </p>

<pre><code>#!C:\python27\python
import feedparser,serial
from set import *
print "Content-Type: text/html"     # HTML is following

 while MAX:

    gmail = feedparser.parse(PROTO + USERNAME + ":" + PASSWORD + "@" + SERVER + PATH)
    total_g = len(gmail.entries)
    facebook = feedparser.parse(FACEBOOKFEED)               # here feedparser does the hard work of loasding the rss feed
    total_f = 1
    if i ==0:
         print ("Unread:{0}".format(total_g))
    if total_g ==0:
            #mySerial.write(0)
            #time.sleep(10)
            print("no mail")
    elif total_g&gt;0:
            gmail_latest = gmail.entries[i]
            g_title = gmail_latest.title
            g_author = gmail_latest.author
            print ("Gmail stream")
            print (g_title)        
            print (g_author)
            print("")
            #mySerial.write("[{0}] {1} ".format(total_g,g_title))
            #time.sleep(20)
            i+=1      
    if total_f ==0:
             #mySerial.write(0)
             #time.sleep(10) 
             print("No New update")     

    elif total_f&gt;0:
             noti = facebook['items'][j].title
             time_f = facebook['items'][j].published
             print("Facebook stream")
             print(noti + "\n"+ time_f) 
             print("") 
             #mySerial.write(noti +"\n"+ time_f)         
             j+=1 
             #time.sleep(20) 


    #tweet = feedparser.parse("https://"+USERNAME+":"+PASSWORD+"@twitter.com/statuses/friends_timeline/" + str(USERID) + ".rss") 
# mySerial.flushOutput()
</code></pre>
