I am trying to build a system in Laravel from which I am able to call some python scripts. Starting with https://github.com/maurosoria/dirsearch, I have placed the python script with the same machine and tried to run on api call.
If I run shall_exec('ls -la'); it runs perfectly and returns me result.
But when I run the following command, the execution ends and no output.
shall_exec("python3 dirsearch-master/dirsearch.py -u https://www.yahoo.com/ -e *");
Then I used https://symfony.com/doc/current/components/process.html and try the same steps
use Symfony\Component\Process\Exception\ProcessFailedException;
use Symfony\Component\Process\Process;
$process = new Process("python3 dirsearch-master/dirsearch.py -u https://www.yahoo.com/ -e *");
$process->run();
// executes after the command finishes
if (!$process->isSuccessful()) {
throw new ProcessFailedException($process);
}
echo $process->getOutput();
In this case also the $process->run(); returns me no result.
new Process(['python3', 'dirsearch-master/dirsearch.py', '-u', 'https://www.yahoo.com/', '-e', '*']);Maybe that's the problem?shell_exec('ls -la dirsearch-master/dirsearch.py');?shell_exec('ls -la dirsearch-master/dirsearch.py')works fine. Then I triednew Process(['python3', 'dirsearch-master/dirsearch.py', '-u', 'https://www.yahoo.com/', '-e', '*']);I get following errorERR > /usr/local/Cellar/python/3.7.4/Frameworks/Python.framework/Versions/3.7/Resources/Python.app/Contents/MacOS/Python: can't open file 'dirsearch-master/dirsearch.py': [Errno 13] Permission deniedI change chmod to 777, still same errorSymfony \ Component \ Process \ Exception \ ProcessFailedException The command "'python3' 'dirsearch-master/dirsearch.py' '-u' 'https://www.yahoo.com/' '*'" failed. Exit Code: 2(Misuse of shell builtins) Working directory: ../public Output: ================ Error Output: ================ /usr/local/Cellar/python/3.7.4/Frameworks/Python.framework/Versions/3.7/Resources/Python.app/Contents/MacOS/Python: can't open file 'dirsearch-master/dirsearch.py': [Errno 13] Permission denied