Howto pass a mixed string from php through a pipe to a bash script
<p>I'm searching for a possibility to send a mixed PHP multline string with the help of proc_open (exec, passthru or whatever) via a pipe to a bash script. Finally, within this script I want to grab the mixed multiline string and store it into a variable.</p>

<h2>PHP:</h2>

<pre><code>// static way
$some_multiline_string = 'some $%§%&amp; mixed &amp;/(/( 
content 
with newlines';

// dynamic way:
// the mixed content is coming from the database
// so actually it is not initialized like in the previous lines, but more like this:
$some_multiline_string = $db_result['some_multiline_string'];

// escaping
$some_multiline_string = escapeshellargs($some_multiline_string);

// execution
$process = proc_open("printf $some_multiline_string | some_script.sh args");
...
</code></pre>

<h2>Bash:</h2>

<pre><code>#!/bin/bash
mixed_multiline_string=$(&lt;/dev/stdin)
echo -e "$mixed_multiline_string"
...
</code></pre>

<p>How to escape the mixed content properly before using it within the command? I've tried already escapeshellargs and escapeshellcmd, but either there is an unescaped charackter, which is stopping the process or it's working but is taking too much time (1.5 min) for processing.</p>

<p>Here is a link to an example mixed content string:
<a href="http://playmobox.com/js/test.txt" rel="nofollow noreferrer">http://playmobox.com/js/test.txt</a></p>

<p>Thanks a lot!</p>