My script doesn't want to recognize the variables from the exec() command in PHP. Plus, it won't capture the results of the script.
This Python script works in IDLE, and I've got some testing code in there. One Known Unsolved Issue: I put Python in C:\Program Files\Python26\python.exe and have tried $command = "C:\Program Files\Python26\python.exe include/weatherFeed.py -c $city -s $state"; to no avail. I added .py to Windows IIS Web Service Extensions and to the Application Configuration. Any help appreciated. [code] #!C:\Program Files\Python26\python.exe -u # Current weather feed # # Weather page sources: http://www.weather.gov/ # Capture relevant data, strip unusable stuff out, fix URLs, display in our HTML page # import program modules import mechanize, re, urllib2, sys # 'standard' set from BeautifulSoup import BeautifulSoup as B_S query = 'Chicago, IL' #test to make sure script works! city = 'Establish' state = 'Variables' count = 0 for ea in sys.argv: if ea == '-c': city = sys.argv[count+1] elif ea == '-s': state = sys.argv[count+1] count+=1 cityState = city + ', ' + state _URL = "http://www.weather.gov/" #_URL = " http://forecast.weather.gov/MapClick.php?CityName=Novato&state=CA&site=MTR&lat=38.1032&lon=-122.63 " br=mechanize.Browser() br.open( _URL ) br.select_form( nr=1 ) #assuming form is 2nd form on page br['inputstring'] = query html = br.submit() _soup = B_S(html) # finding the correct table _step1 = _soup.findAll('table', limit=7)[6] col = _step1.findAll('td') _thumb = '<table><tr><td colspan=2>Forecast for ' + query + '<br>' + str(sys.argv) + '</td></tr><tr>' + str(col[0]) + str(col[1]) + '</tr></table>' _thumb = _thumb.replace( '11%','50%' ) _thumb = _thumb.replace( '/images/', 'images/weather/' ) #write to txt file TEST _temp = 'D:\\Inetpub\\AtoZ\\hometown\\include\\weatherFeed_TEMP.txt' temp = open( _temp, 'w' ) temp.write( _thumb ) temp.close() #print _thumb [/code] And my PHP: [code] <?PHP $city = 'Tampa'; $state = 'FL'; echo '<p><p>Python Weather Feed for ' . $city . ', ' . $state . '<p>'; ob_start(); $command = "include/weatherFeed.py -c " . $city . "-s " . $state; exec($command); $content=ob_get_contents(); ob_end_clean(); echo 'Content: ' . $content . '<br>'; echo 'Result: ' . $result . '<br>'; echo 'Data: ' . $data . '<br>'; include('include\weatherFeed_TEMP.txt') ?>
_______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor