<meta http-equiv="Content-Type" content="text/html; charset=utf-8"><meta name="ProgId" content="Word.Document"><meta name="Generator" content="Microsoft Word 12"><meta name="Originator" content="Microsoft Word 12"><link rel="File-List" href="file:///C:%5CDOCUME%7E1%5CRHINKE%7E1%5CLOCALS%7E1%5CTemp%5Cmsohtmlclip1%5C01%5Cclip_filelist.xml"><link rel="themeData" href="file:///C:%5CDOCUME%7E1%5CRHINKE%7E1%5CLOCALS%7E1%5CTemp%5Cmsohtmlclip1%5C01%5Cclip_themedata.thmx"><link rel="colorSchemeMapping" href="file:///C:%5CDOCUME%7E1%5CRHINKE%7E1%5CLOCALS%7E1%5CTemp%5Cmsohtmlclip1%5C01%5Cclip_colorschememapping.xml"><style>
<!--
 /* Font Definitions */
 @font-face
        {font-family:"Cambria Math";
        panose-1:2 4 5 3 5 4 6 3 2 4;
        mso-font-charset:1;
        mso-generic-font-family:roman;
        mso-font-format:other;
        mso-font-pitch:variable;
        mso-font-signature:0 0 0 0 0 0;}
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;
        mso-font-charset:0;
        mso-generic-font-family:swiss;
        mso-font-pitch:variable;
        mso-font-signature:-1610611985 1073750139 0 0 159 0;}
 /* Style Definitions */
 p.MsoNormal, li.MsoNormal, div.MsoNormal
        {mso-style-unhide:no;
        mso-style-qformat:yes;
        mso-style-parent:"";
        margin:0in;
        margin-bottom:.0001pt;
        mso-pagination:widow-orphan;
        font-size:11.0pt;
        font-family:"Calibri","sans-serif";
        mso-fareast-font-family:Calibri;
        mso-fareast-theme-font:minor-latin;
        mso-bidi-font-family:"Times New Roman";}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:blue;
        text-decoration:underline;
        text-underline:single;}
a:visited, span.MsoHyperlinkFollowed
        {mso-style-noshow:yes;
        mso-style-priority:99;
        color:purple;
        mso-themecolor:followedhyperlink;
        text-decoration:underline;
        text-underline:single;}
code
        {mso-style-noshow:yes;
        mso-style-priority:99;
        font-family:"Courier New";
        mso-ascii-font-family:"Courier New";
        mso-fareast-font-family:Calibri;
        mso-fareast-theme-font:minor-latin;
        mso-hansi-font-family:"Courier New";
        mso-bidi-font-family:"Courier New";}
.MsoChpDefault
        {mso-style-type:export-only;
        mso-default-props:yes;
        font-size:10.0pt;
        mso-ansi-font-size:10.0pt;
        mso-bidi-font-size:10.0pt;}
@page Section1
        {size:8.5in 11.0in;
        margin:1.0in 1.0in 1.0in 1.0in;
        mso-header-margin:.5in;
        mso-footer-margin:.5in;
        mso-paper-source:0;}
div.Section1
        {page:Section1;}
-->
</style>

<p class="MsoNormal" style="margin-bottom: 12pt;">My script doesn&#39;t want to
recognize the variables from the exec() command in PHP. Plus, it won&#39;t capture
the results of the script.<br>
<br>
This Python script works in IDLE, and I&#39;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.</p>

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

<p class="MsoNormal">[code]</p>

<p class="MsoNormal" style="margin-left: 0.5in;"><code><span style="font-size: 10pt;">#!C:\Program
Files\Python26\python.exe -u</span></code><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;"><br>
<code># Current weather feed</code><br>
<code># # Weather page sources: <a href="http://www.weather.gov/">http://www.weather.gov/</a></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 # &#39;standard&#39; set</code><br>
<code>from BeautifulSoup import BeautifulSoup as B_S</code><br>
<br>
<code>query = &#39;Chicago, IL&#39; #test to make sure script works!</code><br>
<code>city = &#39;Establish&#39;</code><br>
<code>state = &#39;Variables&#39;</code><br>
<code>count = 0</code><br>
<code>for ea in sys.argv:</code><br>
<code>    if ea == &#39;-c&#39;:</code><br>
<code>        city = sys.argv[count+1]</code><br>
<code>    elif ea == &#39;-s&#39;:</code><br>
<code>        state = sys.argv[count+1]</code><br>
<code>    count+=1</code><br>
<code>cityState = city + &#39;, &#39; + state</code><br>
<br>
<code>_URL = &quot;<a href="http://www.weather.gov/">http://www.weather.gov/</a>&quot;</code><br>
<code>#_URL = &quot;<a href="http://forecast.weather.gov/MapClick.php?CityName=Novato&amp;state=CA&amp;site=MTR&amp;lat=38.1032&amp;lon=-122.63">http://forecast.weather.gov/MapClick.php?CityName=Novato&amp;state=CA&amp;site=MTR&amp;lat=38.1032&amp;lon=-122.63</a>&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[&#39;inputstring&#39;] = 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(&#39;table&#39;, limit=7)[6]</code><br>
<code>col = _step1.findAll(&#39;td&#39;)</code><br>
<code>_thumb = &#39;&lt;table&gt;&lt;tr&gt;&lt;td colspan=2&gt;Forecast for &#39; +
query + &#39;&lt;br&gt;&#39; + str(sys.argv) + &#39;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&#39; +
str(col[0]) + str(col[1]) + &#39;&lt;/tr&gt;&lt;/table&gt;&#39;</code><br>
<code>_thumb = _thumb.replace( &#39;11%&#39;,&#39;50%&#39; )</code><br>
<code>_thumb = _thumb.replace( &#39;/images/&#39;, &#39;images/weather/&#39; )</code><br>
<br>
<code>#write to txt file TEST</code><br>
<code>_temp = &#39;D:\\Inetpub\\AtoZ\\hometown\\include\\weatherFeed_TEMP.txt&#39;</code><br>
<code>temp = open( _temp, &#39;w&#39; )</code><br>
<code>temp.write( _thumb )</code><br>
<code>temp.close()</code><br>
<br>
<code>#print _thumb</code></span></p>

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

<p class="MsoNormal">[code]</p>

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

<p class="MsoNormal"> </p>


<div style="visibility: hidden; display: inline;" id="avg_ls_inline_popup"></div><style type="text/css">#avg_ls_inline_popup {  position:absolute;  z-index:9999;  padding: 0px 0px;  margin-left: 0px;  margin-top: 0px;  width: 240px;  overflow: hidden;  word-wrap: break-word;  color: black;  font-size: 10px;  text-align: left;  line-height: 13px;}</style>