How to store output of a python program in command prompt?
<p>I'm passing run time variable from command prompt to python to execute there (im=n python). Now I want to store the result of python program and use those results back into command prompt. Sample is as follows</p>

<pre><code>set input=
set /P input=Enter Layer Name:%=%
C:\Python27\python.exe F:\xampp\htdocs\flood_publish\projection_raster.py %input%
</code></pre>

<p>I'm passing user input string to python program from command prompt as above.
How use the result of python program back into command prompt</p>

<p>Let me know if this helps.</p>

<p><strong>Code of python file (c.py):</strong></p>

<pre><code>import sys

print('You passed ',sys.argv[1])
</code></pre>

<p><strong>Windows Batch Code (a.bat) :</strong></p>

<pre><code>@echo off

set input=

set /P input=Enter Layer Name:%=%

(python c.py %input%) &gt; tmp.txt

set /P output=&lt;tmp.txt

echo %output%
</code></pre>

<p>
 <strong>Output of batch code:</strong></p>

<pre><code>C:\Users\dinesh_pundkar\Desktop&gt;a.bat
Enter Layer Name:Dinesh
You passed  Dinesh
C:\Users\dinesh_pundkar\Desktop&gt;
</code></pre>

python shell cmd runtime parameter-passing