How i can run shell command via a Model or Controller. Not through Artisan command or $schedule.
And also how i can run a sudo command?
I have try the next options. Nothing works:
1:
$process = new Process('sudo /usr/bin/touch /var/www/html/Poptin test2.html');
$process->run();
// executes after the command finishes
if (!$process->isSuccessful()) {
throw new ProcessFailedException($process);
}
2:
shell_exec(escapeshellcmd('sudo /usr/bin/touch /var/www/html/Poptin test2.html));
3:
exec('sudo /usr/bin/touch /var/www/html/Poptin test2.html);
Help please!