パイプを介してbashスクリプトにproc_open(exec、passthruなど)を使用して、混合PHPマルチライン文字列を送信する可能性を探しています。最後に、このスクリプト内で、混合された複数行の文字列を取得して変数に格納します。
PHP:
// static way
$some_multiline_string = 'some $%§%& mixed &/(/(
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");
...
バッシュ:
#!/bin/bash
mixed_multiline_string=$(</dev/stdin)
echo -e "$mixed_multiline_string"
...
コマンド内で使用する前に、混合コンテンツを適切にエスケープする方法は? 私はすでに escapeshellargs と escapeshellcmd を試しましたが、プロセスを停止しているエスケープされていない文字があるか、動作しているが処理に時間がかかりすぎています (1.5 分)。
混合コンテンツ文字列の例へのリンクは次のとおりです: http://playmobox.com/js/test.txt
どうもありがとう!