<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">

<head>
<meta http-equiv=Content-Type content="text/html; charset=us-ascii">
<meta name=Generator content="Microsoft Word 12 (filtered medium)">
<style>
<!--
 /* Font Definitions */
 @font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
 /* Style Definitions */
 p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0in;
        margin-bottom:.0001pt;
        font-size:11.0pt;
        font-family:"Calibri","sans-serif";}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:blue;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {mso-style-priority:99;
        color:purple;
        text-decoration:underline;}
code
        {mso-style-priority:99;
        font-family:"Courier New";}
span.EmailStyle17
        {mso-style-type:personal-compose;
        font-family:"Calibri","sans-serif";
        color:windowtext;}
.MsoChpDefault
        {mso-style-type:export-only;}
@page Section1
        {size:8.5in 11.0in;
        margin:1.0in 1.0in 1.0in 1.0in;}
div.Section1
        {page:Section1;}
-->
</style>
<!--[if gte mso 9]><xml>
 <o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
 <o:shapelayout v:ext="edit">
  <o:idmap v:ext="edit" data="1" />
 </o:shapelayout></xml><![endif]-->
</head>

<body lang=EN-US link=blue vlink=purple>

<div class=Section1>

<p class=MsoNormal style='margin-bottom:12.0pt'>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.<br>
<br>
This Python script works in IDLE, and I've got some testing code in there.<br>
<br>
One Known Unsolved Issue:<br>
I put Python in C:\Program Files\Python26\python.exe and have tried<br>
$command = &quot;C:\Program Files\Python26\python.exe include/weatherFeed.py -c
$city -s $state&quot;;<br>
to no avail.<o:p></o:p></p>

<p class=MsoNormal style='margin-bottom:12.0pt'>I added .py to Windows IIS Web
Service Extensions and to the Application Configuration.<br>
<br>
Any help appreciated.<o:p></o:p></p>

<p class=MsoNormal>[code]<o:p></o:p></p>

<p class=MsoNormal style='margin-left:.5in'><code><span style='font-size:10.0pt'>#!C:\Program
Files\Python26\python.exe -u</span></code><span style='font-size:10.0pt;
font-family:"Courier New"'><br>
<code># Current weather feed</code><br>
<code># # Weather page sources: http://www.weather.gov/</code><br>
<code># Capture relevant data, strip unusable stuff out, fix URLs, display in
our HTML page</code><br>
<br>
<code># import program modules</code><br>
<code>import mechanize, re, urllib2, sys # 'standard' set</code><br>
<code>from BeautifulSoup import BeautifulSoup as B_S</code><br>
<br>
<code>query = 'Chicago, IL' #test to make sure script works!</code><br>
<code>city = 'Establish'</code><br>
<code>state = 'Variables'</code><br>
<code>count = 0</code><br>
<code>for ea in sys.argv:</code><br>
<code>&nbsp; &nbsp; if ea == '-c':</code><br>
<code>&nbsp; &nbsp; &nbsp; &nbsp; city = sys.argv[count+1]</code><br>
<code>&nbsp; &nbsp; elif ea == '-s':</code><br>
<code>&nbsp; &nbsp; &nbsp; &nbsp; state = sys.argv[count+1]</code><br>
<code>&nbsp; &nbsp; count+=1</code><br>
<code>cityState = city + ', ' + state</code><br>
<br>
<code>_URL = &quot;http://www.weather.gov/&quot;</code><br>
<code>#_URL =
&quot;http://forecast.weather.gov/MapClick.php?CityName=Novato&amp;state=CA&amp;site=MTR&amp;lat=38.1032&amp;lon=-122.63&quot;</code><br>
<br>
<code>br=mechanize.Browser()</code><br>
<code>br.open( _URL )</code><br>
<code>br.select_form( nr=1 ) #assuming form is 2nd form on page</code><br>
<code>br['inputstring'] = query</code><br>
<code>html = br.submit()</code><br>
<br>
<code>_soup = B_S(html)</code><br>
<br>
<code># finding the correct table</code><br>
<code>_step1 = _soup.findAll('table', limit=7)[6]</code><br>
<code>col = _step1.findAll('td')</code><br>
<code>_thumb = '&lt;table&gt;&lt;tr&gt;&lt;td colspan=2&gt;Forecast for ' +
query + '&lt;br&gt;' + str(sys.argv) + '&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;' +
str(col[0]) + str(col[1]) + '&lt;/tr&gt;&lt;/table&gt;'</code><br>
<code>_thumb = _thumb.replace( '11%','50%' )</code><br>
<code>_thumb = _thumb.replace( '/images/', 'images/weather/' )</code><br>
<br>
<code>#write to txt file TEST</code><br>
<code>_temp = 'D:\\Inetpub\\AtoZ\\hometown\\include\\weatherFeed_TEMP.txt'</code><br>
<code>temp = open( _temp, 'w' )</code><br>
<code>temp.write( _thumb )</code><br>
<code>temp.close()</code><br>
<br>
<code>#print _thumb</code></span><o:p></o:p></p>

<p class=MsoNormal>[/code]<br>
<br>
And my PHP:<o:p></o:p></p>

<p class=MsoNormal>[code]<o:p></o:p></p>

<p class=MsoNormal style='margin-left:.5in'><code><span style='font-size:10.0pt'>&lt;?PHP</span></code><span
style='font-size:10.0pt;font-family:"Courier New"'><br>
<code>&nbsp; &nbsp;&nbsp; &nbsp;$city = 'Tampa';</code><br>
<code>&nbsp; &nbsp;&nbsp; &nbsp;$state = 'FL';</code><br>
<code>&nbsp; &nbsp;&nbsp; &nbsp;echo&nbsp; '&lt;p&gt;&lt;p&gt;Python Weather
Feed for ' . $city . ', ' . $state . '&lt;p&gt;';</code><br>
<br>
<code>&nbsp; &nbsp;&nbsp; &nbsp;ob_start();</code><br>
<code>&nbsp; &nbsp;&nbsp; &nbsp;$command = &quot;include/weatherFeed.py -c &quot;
. $city . &quot;-s &quot; . $state;</code><br>
<code>&nbsp; &nbsp;&nbsp; &nbsp;exec($command);</code><br>
<code>&nbsp; &nbsp;&nbsp; &nbsp;$content=ob_get_contents();</code><br>
<code>&nbsp; &nbsp;&nbsp; &nbsp;ob_end_clean();</code><br>
<code>&nbsp; &nbsp;&nbsp; &nbsp;</code><br>
<code>&nbsp; &nbsp;&nbsp; &nbsp;echo 'Content: ' . $content . '&lt;br&gt;';</code><br>
<code>&nbsp; &nbsp;&nbsp; &nbsp;echo 'Result: ' . $result . '&lt;br&gt;';</code><br>
<code>&nbsp; &nbsp;&nbsp; &nbsp;echo 'Data: ' . $data . '&lt;br&gt;';</code><br>
<code>&nbsp; &nbsp;&nbsp; &nbsp;include('include\weatherFeed_TEMP.txt')</code><br>
<code>&nbsp; &nbsp;?&gt;</code></span><o:p></o:p></p>

<p class=MsoNormal><o:p>&nbsp;</o:p></p>

<p class=MsoNormal><o:p>&nbsp;</o:p></p>

<p class=MsoNormal><span style='font-size:10.0pt;font-family:"Arial","sans-serif"'>Roy
Hinkelman<br>
Technical Services<br>
Website Development &amp; Management<br>
707-774-7411<br>
</span><a href="mailto:roy@worldtradepress.com"><span style='font-size:10.0pt;
font-family:"Arial","sans-serif";color:blue'>roy@worldtradepress.com</span></a><br>
<span style='font-size:10.0pt;font-family:"Arial","sans-serif"'>________________________________<br>
<span style='color:#999999'>www.WorldTradePress.com (main website)<br>
www.StockMapAgency.com (3700+ Antique &amp; Modern Maps)<br>
www.BestCountryReports.com (country reports for 175 countries)<br>
www.GiantMapArt.com (giant wall maps)<br>
www.WorldTradeRef.com (trade and logistics)<br>
www.GlobalRoadWarrior.com (175-country database) <br>
www.AtoZMapsOnline.com (worlds largest map database)<br>
<a href="http://www.AtoZtheUSA.com"><span style='color:gray'>www.AtoZtheUSA.com</span></a></span><span
style='color:gray'> (extensive state facts database)<o:p></o:p></span></span></p>

<p class=MsoNormal><o:p>&nbsp;</o:p></p>

</div>

</body>

</html>