Is there any way to make popen supports operators like &, | etc?
Example:
$cmd = "/bin/sh -c" . " \"" . "whoami && uname" ."\"";
$han = popen($cmd, 'r');
echo(fread($han, 2096));
pclose($han);
Just the first command ( whoami ) gets executed rather than both
I know there are other functions, but I'm talking just about popen
My Answer:
`|`, `&&`, `||`, etc.?
No, `popen` does not support operators like `|`, `&&`, `||`, etc. `popen` is used to open a process by creating a pipe, which allows communication between the parent process and the child process. It does not support shell operators for chaining commands or controlling the flow of execution. If you need to use shell operators, you can use `proc_open` instead, which allows more control over the execution of commands and supports shell operators.
Rate this post
3 of 5 based on 7687 votesComments