title: How to let Kubernetes pod run a local script
body: <p>I want to run a local script within Kubernetes pod and then set the output result to a linux variable</p>
  <p>Here is what I tried:</p>
  <pre><code># if I directly run -c &quot;netstat -pnt |grep ssh&quot;, I get output assigned to $result:
  
  cat check_tcp_conn.sh 
  #!/bin/bash
  result=$(kubectl exec -ti &lt;pod_name&gt; -- /bin/bash -c &quot;netstat -pnt |grep ssh&quot;)
  echo &quot;result is $result&quot;
  </code></pre>
  <p>What I want is something like this:</p>
  <pre><code>#script to be called:
  cat netstat_tcp_conn.sh
  #!/bin/bash
  netstat -pnt |grep ssh
  
  #script to call netstat_tcp_conn.sh:
  cat check_tcp_conn.sh 
  #!/bin/bash
  result=$(kubectl exec -ti &lt;pod_name&gt; -- 
  /bin/bash -c &quot;./netstat_tcp_conn.sh)
  echo &quot;result is $result
  </code></pre>
  <p>the result showed <code>result is /bin/bash: ./netstat_tcp_conn.sh: No such file or directory</code>.</p>
  <p>How can I let Kubernetes pod execute netstat_tcp_conn.sh which is at my local machine?</p>