passing argument from python to subprocess.popen
<p>I have this code:</p>

<pre><code>from subprocess import Popen
link="abc"
theproc = Popen([sys.executable, "p1.py",link])
</code></pre>

<p>I want to send the variable "link" to p1.py,
and p1.py will print it.</p>

<p>something like this. here is p1.py:</p>

<pre><code>print "in p1.py link is "+ link
</code></pre>

<p>How can I do that?</p>

<p>You have to parse the command line arguments in your <code>p1.py</code> to get it in a variable:</p>

<pre><code>import sys
try:
    link = sys.argv[1]
except IndexError:
    print 'argument missing'
    sys.exit(1)
</code></pre>

python subprocess popen