title: How I can pass bash variable inside python command?
body: <p>I want to pass variable server inside python command and read the python command result portStatus variable out from command.</p>
  <pre><code>for server in `echo $dnsServers | awk -F&quot;;&quot; '{print $1&quot; &quot;$2&quot; &quot;$3&quot; &quot;$4&quot; &quot;$5&quot; &quot;$6}'`
    do
      python3 -c 'import socket;
      a_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM);
      host=(&quot;$server&quot;, 53); 
      portStatus=a_socket.connect_ex(host);'
    done
  echo $portStatus
  
  
  </code></pre>
  <p>Getting this error :</p>
  <pre><code>Traceback (most recent call last):
    File &quot;&lt;string&gt;&quot;, line 1, in &lt;module&gt;
  socket.gaierror: [Errno -2] Name or service not known
  Traceback (most recent call last):
    File &quot;&lt;string&gt;&quot;, line 1, in &lt;module&gt;
  socket.gaierror: [Errno -2] Name or service not known
  Traceback (most recent call last):
  </code></pre>