I'm tring to pass a string to a batch file from php using proc_open()
on Windows. It works fine unless the string I'm passing is multiline, because it breaks the command with the line break. I tried various escaping methods, but none of them seems to work:
cmd style - prints the escape symbol and breaks line:
proc_open('script.bat -m "this is ^\n multiline"', $desc, $pipes)
another try - prints the whole string:
proc_open('script.bat -m "this is ^\\n multiline"', $desc, $pipes)
powershell style - prints the whole string:
proc_open('script.bat -m "this is `n multiline"', $desc, $pipes)
No matter what I tried, it either breaks the string anyway, or prints it as is, with no line break.
What am I missing or doing wrong? How to get multiline arguments to work via proc_open()
?