PHP is having issues executing commands that have -- in it for parameters. I'm running this on Linux.
Please look at the code below:
I was trying various ways to get PHP to execute a command on the CLI.Code://$theCommand = 'myProgram list stuff --parameter1=hello,world,something,else'; //$theCommand = 'myProgram list stuff "column1:name column2:age" --parameter1=hello,world,something,else'; //$theCommand = 'myProgram list stuff sometime'; //$theCommand = 'myProgram list stuff ' . chr(45) . chr(45) . 'parameter1=hello,world,something,else'; //$theCommand = 'myProgram list stuff "column1:name column2:age"'; //$theResult = shell_exec($theCommand); //exec($theCommand, $theReturn); echo $theCommand . " <br /><br />"; passthru($theCommand, $theReturn); print_r ($theReturn);
If I use:
It will return just 1 as the return.Code:$theCommand = 'myProgram list stuff --parameter1=hello,world,something,else';
If I then try:
It will return 0, and some output (Column headers), but it's almost like I didn't specify anything to search for.$theCommand = 'myProgram list stuff "column1:name column2:age"';
If I just run:
It works fine.Code:$theCommand = 'myProgram list stuff sometime';
I can run any of these commands in CLI and they all work fine.
I've tried shell_exec(), exec() and passthru().
Any suggestions?


Reply With Quote