123456789101112131415161718192021222324252627282930313233343536373839 |
- <?php
- /**
- * Created by PhpStorm.
- * User: robin
- * Date: 11/24/15
- * Time: 5:17 PM
- */
-
- namespace App\Http\Business\Commands;
-
-
- class WakeOnLanCommand extends AbstractCommand
- {
-
- /**
- * @return bool
- */
- public function exec()
- {
- $data = $this->_command->getData();
- $args = [
- 'wakeonlan',
- '-i',
- $data['IP'],
- '-p',
- $data['Port']
- ];
- foreach ($data["MACs"] as $mac) {
- $args[] = $mac;
- }
- $cli = implode(' ', $args);
- $code = 0;
- $output = [];
- exec($cli, $output, $code);
- if ($code != 0) {
- abort(500, "Wakeonlan failed with code " . $code);
- }
- }
- }
|