I have a binary that takes input from stdin that I use on the command line by piping file contents to it like cat query.sql | go-mysql-format
, but how do I pipe a variable to the executable?
Currently I have
file_put_contents($File = "$_SERVER[DOCUMENT_ROOT]/tmp/" . uuid(), $MySQL);
$o = shell_exec('cat ' . escapeshellarg($File) . ' | go-mysql-format --html');
Basically I would like to skip the file creation.
It's also important to note that the data will contain newlines, so I'm not sure wrapping the variable with escapeshellarg
will be appropriate