How can i take the output of one python script as user input for another python script
<p>i have written a code (python 2.7) that goes to a website <a href="http://www.cricbuzz.com/live-cricket-scorecard/16822/ind-vs-nz-1st-test-new-zealand-tour-of-india-2016" rel="nofollow">Cricket score</a> and then takes out some data out of it to display just its score .It also periodically repeats and keeps running because the scores keep changing.
i have also written a code for taking a message input from user and send that message as an sms to my number .</p>

<p>i want to club these two so that the scores printed on my screen serve as the message input for sending live scores to me.</p>

<p>codes are</p>

<p><strong>sms.py</strong></p>

<pre><code>    import urllib2
    import cookielib
    from getpass import getpass
    import sys
    import os
    from stat import *
    import sched, time
    import requests
    from bs4 import BeautifulSoup
    s = sched.scheduler(time.time, time.sleep)
    from urllib2 import Request
    #from livematch import function

    #this sends the desired input message to my number


    number = raw_input('enter number you want to message:  ')
    message = raw_input('enter text: ' ) 


    #this declares my credentials
    if __name__ == "__main__":    
        username = "9876543210"
        passwd = "abcdefghij"

        message = "+".join(message.split(' '))

     #logging into the sms site
        url ='http://site24.way2sms.com/Login1.action?'
        data = 'username='+username+'&amp;password='+passwd+'&amp;Submit=Sign+in'

     #For cookies

        cj= cookielib.CookieJar()
        opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(cj))

     #Adding header details
        opener.addheaders=[('User-Agent','Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/37.0.2062.120')]
        try:
            usock =opener.open(url, data)
       except IOError:
            print "error"
            #return()

        jession_id =str(cj).split('~')[1].split(' ')[0]
        send_sms_url = 'http://site24.way2sms.com/smstoss.action?'
        send_sms_data = 'ssaction=ss&amp;Token='+jession_id+'&amp;mobile='+number+'&amp;message='+message+'&amp;msgLen=136'
        opener.addheaders=[('Referer', 'http://site25.way2sms.com/sendSMS?Token='+jession_id)]
        try:
            sms_sent_page = opener.open(send_sms_url,send_sms_data)
        except IOError:
            print "error"
            #return()

        print "success" 
        #return ()    
</code></pre>

<p><strong>livematch.py</strong></p>

<pre><code>    import sched, time
    import requests
    from bs4 import BeautifulSoup
    s = sched.scheduler(time.time, time.sleep)
    from urllib2 import Request

    url=raw_input('enter the desired score card url here :  ')
    req=Request(url)
    def do_something(sc) : 
        #global x
        r=requests.get(url)
        soup=BeautifulSoup(r.content)
        for i in soup.find_all("div",{"id":"innings_1"}):
          x=i.text.find('Batsman')
          in_1=i.text
          print(in_1[0:x])
        for i in soup.find_all("div",{"id":"innings_2"}):
          x=i.text.find('Batsman')
          in_1=i.text
          print(in_1[0:x])
        for i in soup.find_all("div",{"id":"innings_3"}):
          x=i.text.find('Batsman')
          in_1=i.text
          print(in_1[0:x])
        for i in soup.find_all("div",{"id":"innings_4"}):
          x=i.text.find('Batsman')
          in_1=i.text
          print(in_1[0:x])
        # do your stuff
            #do what ever 
        s.enter(5, 1, do_something, (sc,))

    s.enter(5, 1, do_something, (s,))
    s.run()
</code></pre>

<p>note that instead of using 9876543210 as username and abcdefghij as password use the credentials of actual account.</p>

<p>sign up at way2sms.com for those credentials</p>

<p>It is hard to answer without having a look at your code. But it seems that using piping with subprocess would be an appropriate solution. </p>

<p>See the answer on this post: <a href="http://stackoverflow.com/questions/32812157/python-subprocess-stdout-readline-doesnt/32812754#32812754">python subprocess.stdout.readline doesn&#39;t</a></p>

python python-2.7 windows-10