I'm trying to automate these steps using a bash script
Run a command to access the shell of a program (bash shell of a Kubernetes pod)
kubectl exec --stdin --tty hello-node-7567d9fdc9-zvz55 -- bashIn this shell, run a second command (eg.
python)root@hello-node-7567d9fdc9-zvz55:/# python Python 3.7.4 (default, Aug 13 2019, 15:17:50) [Clang 4.0.1 (tags/RELEASE_401/final)] :: Anaconda, Inc. on linux Type "help", "copyright", "credits" or "license" for more information. >>>Keep the shell open/running in the foreground (so more commands can immediately be entered by a user into the python shell started in step 2)
I'm able to do the first step described above using the script below. How do we do the second and third step?
#! /bin/bash
bash -c 'kubectl exec --stdin --tty hello-node-7567d9fdc9-zvz55 -- bash'
pexpectscriptpython -c 'print("hello from python"); print ("hi")'for supplying multiple python commandsbash -c 'kubectl …'with justkubectl …: there’s absolutely no reason to spawn yet another shell process inside your shell script.