<p>I'm writing a shell script which needs to login into the pod and execute a series of commands in a kubernetes pod.</p>
<p>Below is my sample_script.sh:</p>
<pre><code>kubectl exec octavia-api-worker-pod-test -c octavia-api bash
unset http_proxy https_proxy
mv /usr/local/etc/octavia/octavia.conf /usr/local/etc/octavia/octavia.conf-orig
/usr/local/bin/octavia-db-manage --config-file /usr/local/etc/octavia/octavia.conf upgrade head
</code></pre>
<p>After running this script, I'm not getting any output.
Any help will be greatly appreciated</p>

<p>Are you running all these commands as a single line command? First of all, there's no <code>;</code> or <code>&amp;&amp;</code> between those commands. So if you paste it as a multi-line script to your terminal, likely it will get executed locally.</p>

<p>Second, to tell bash to execute something, you need: <code>bash -c "command"</code>.</p>

<p>Try running this:</p>

<pre><code>$ kubectl exec POD_NAME -- bash -c "date &amp;&amp; echo 1"

Wed Apr 19 19:29:25 UTC 2017
1
</code></pre>

<p>You can make it multiline like this:</p>

<pre><code>$ kubectl exec POD_NAME -- bash -c "date &amp;&amp; \
      echo 1 &amp;&amp; \
      echo 2"
</code></pre>
