Home > database >  Call to undefined function App\Http\Controllers\exec()
Call to undefined function App\Http\Controllers\exec()

Time:10-24

Please help me. The website works fine in the local host, but it is having error in the C panel. How to solve? the path is: app/config/app.php

CodePudding user response:

From your image, I'm supposing you defined the public function exec() function somewhere above or below in your controller. You cannot reference to it that way since its a method in your controller class.

So change it to this instead. $macAddr = $this->exec('getmac');

CodePudding user response:

you can use Process Component of Symfony that is already in Laravel

http://symfony.com/doc/current/components/process.html

use Symfony\Component\Process\Process;
use Symfony\Component\Process\Exception\ProcessFailedException;

inside your elcdetails use

$macAddr = new Process('getmac');
$macAddr->run();

// executes after the command finishes
if (!$macAddr->isSuccessful()) {
    throw new ProcessFailedException($macAddr;
}

//or whatever you want to do with the output. 

echo $macAddr->getOutput();

note that, if you are trying to get the client mac address, short answer is you cannot.

  • Related