_command->getData(); $args = [ 'camotion-pifaceo' ]; foreach ($data["Commands"] as $cmd) { $args[] = escapeshellarg("--" . $cmd); } $cli = implode(' ', $args); $code = 0; $output = []; exec($cli, $output, $code); if ($code != 0) { abort(500, "PiFace failed with code " . $code); } } }