<p>Helllo does any one have an idea and can help here ?
- I can not run a for me very complicated curl command i have some troubles to understand why its not working</p>

<p>I try to copy data via curl into a Wordpress Directory - at a POD from Kubernetes</p>

<pre><code>kubectl exec $WPPOD -- curl --request GET --header 'PRIVATE-TOKEN: *******' 'https://gitlab.com/api/v4/projects/*****/repository/files/infrastructure%2Fwordpress%2Fdeploy%2Fall-in-one-wp-migration-unlimited-extension%2Ezip/raw?ref=Add_WP_MySQL' &gt; /var/www/html/wp-content/ai1wm-backups                                     
sh: 7: cannot create  /var/www/html/wp-content/ai1wm-backups -: Directory nonexistent
</code></pre>

<p>Also from within the cube this is not working</p>

<pre><code># curl --request GET --header 'PRIVATE-TOKEN: Z7-RByYpUJcnWU_STpuz' 'https://gitlab.com/api/v4/projects/14628452/repository/files/infrastructure%2Fwordpress%2Fdeploy%2Fall-in-one-wp-migration-unlimited-extension%2Ezip/raw?ref=Add_WP_MySQL' &gt; /var/www/html/wp-content/ai1wm-backups/all-in-one-wp-migration-unlimited-extension.zip -O -J -L
sh: 3: cannot create  /var/www/html/wp-content/ai1wm-backups/all-in-one-wp-migration-unlimited-extension.zip -O -J -L: Directory nonexistent
</code></pre>

<p>But if i check the directory within the cube it is fine </p>

<pre><code># cd /var/www/html/wp-content/ai1wm-backups
# ls
index.php  web.config
</code></pre>

<p>Thanks to the helpful input i have now a solution</p>

<pre><code>kubectl exec $WPPOD -- curl --fail --output /var/www/html/wp-content/ai1wm-backups/all-in-one-wp-migration-unlimited-extension.zip --request GET --header 'PRIVATE-TOKEN: *******' 'https://gitlab.com/api/v4/projects/*****/repository/files/infrastructure%2Fwordpress%2Fdeploy%2Fall-in-one-wp-migration-unlimited-extension%2Ezip/raw?ref=Add_WP_MySQL'
</code></pre>

Bliv_Dev
<p>You have two pieces of bad shell going on here:</p>

<p>The first one is because the redirection is happening <strong>on your machine</strong>. The second is because everything after the <code>&gt;</code> is a filename, but you have included random arguments to <code>curl</code> in them.</p>

<p>To solve the first one, package the whole command into a shell literal:</p>

<pre><code>kubectl exec $WPPOD -- sh -c "curl --request GET --header 'PRIVATE-TOKEN: *******' 'https://gitlab.com/api/v4/projects/*****/repository/files/infrastructure%2Fwordpress%2Fdeploy%2Fall-in-one-wp-migration-unlimited-extension%2Ezip/raw?ref=Add_WP_MySQL' &gt; /var/www/html/wp-content/ai1wm-backups"
</code></pre>

<p>I would even go so far as to say "don't use redirection," since if you inform <code>curl</code> of the output file, and add <code>--fail</code> to it, then it will avoid writing to that file on server error, which isn't true when using a shell redirection: the shell <strong>will</strong> create that file, no matter what, possibly making it empty; thus:</p>

<pre><code>kubectl exec $WPPOD -- curl --fail --output /var/www/html/wp-content/ai1wm-backups --request GET --header 'PRIVATE-TOKEN: *******' 'https://gitlab.com/api/v4/projects/*****/repository/files/infrastructure%2Fwordpress%2Fdeploy%2Fall-in-one-wp-migration-unlimited-extension%2Ezip/raw?ref=Add_WP_MySQL'
</code></pre>

<p>For the second problem, it's a simple matter of re-arranging the arguments to be compliant with shell syntax:</p>

<pre><code>curl  -O -J -L --request GET --header 'PRIVATE-TOKEN: Z7-RByYpUJcnWU_STpuz' 'https://gitlab.com/api/v4/projects/14628452/repository/files/infrastructure%2Fwordpress%2Fdeploy%2Fall-in-one-wp-migration-unlimited-extension%2Ezip/raw?ref=Add_WP_MySQL' &gt; /var/www/html/wp-content/ai1wm-backups/all-in-one-wp-migration-unlimited-extension.zip
</code></pre>

<p>Although in that case, you have conflicting <code>curl</code> behaviors: <a href="https://curl.haxx.se/docs/manpage.html#-O" rel="nofollow noreferrer">the <code>-O</code> option</a> is going to write out the file <em>in the current directory</em>, so your shell redirect is only going to receive any messages written by <code>curl</code>, and <em>not</em> the content of that URL</p>

<p>All of this has nothing to do with kubernetes, or a directory, or a copy, and those tags should be removed.</p>
