<p>I am trying to create a copy of a file within a container using kubernetes python api.</p>

<p>Below is the function I want to create:</p>

<pre><code>def create_file_copy(self, file_name, pod_name, pod_namespace=None):
        if pod_namespace is None:
            pod_namespace = self.svc_ns
        stream(self.v1.connect_get_namespaced_pod_exec, name = pod_name, namespace = self.svc_ns ,command=['/bin/sh', '-c', 'cp file_name file_name_og'], stderr=True, stdin=True, stdout=True, tty=True)
</code></pre>

<p>NOTE: self.v1 is a kubernetes client api object which can access the kubernetes api methods.</p>

<p>My question is around how do I parameterize file_name in "cp file_name file_name_og" in the command parameter ?</p>

<p>No an expert in linux commands so any help is appreciated. Thanks</p>

user_11077035
<p>Assuming that both <code>file_name</code> and <code>file_name_og</code> are to be parameterized, this will make the <code>cp</code> copy command be constructed dynamically from function's arguments:</p>

<pre><code>def create_file_copy(self, file_name, file_name_og, pod_name, pod_namespace=None):
    if pod_namespace is None:
        pod_namespace = self.svc_ns
    stream(self.v1.connect_get_namespaced_pod_exec, name = pod_name, namespace = self.svc_ns ,command=['/bin/sh', '-c', 'cp "' + file_name + '" "' + file_name_og + '"'], stderr=True, stdin=True, stdout=True, tty=True)
</code></pre>
