public function generateTestAndKey() { // if($missing = $this->getMissingParams(['title', 'copyright'])) { // return response()->json(['error' => 'Missing params', 'missing' => $missing], 422); // } $uniqId = uniqid(); // putenv("LANG='en_US.UTF-8'"); // putenv("LC_ALL='en_US.UTF-8'"); $shell = new Exec(); $cmd = new CommandBuilder(env('RUDI_PATH', './rudi/rudi')); $cmd->addArgument('output', './' . $uniqId); if (Input::has('title')) { $cmd->addArgument('title', Input::get('title')); } if (Input::has('copyright')) { $cmd->addArgument('copyright', Input::get('copyright')); } foreach ($this->nameToArgument as $name => $arg) { if (Input::has($name)) { if (Input::has($name . "-count")) { $cmd->addArgument($arg, Input::get($name . "-count")); } else { $cmd->addArgument($arg); } } } \Log::info($cmd); $shell->run($cmd); if ($shell->getReturnValue() !== 0) { return response()->json($shell->getOutput(), 500); } $output = ''; $testString = 'lilypond ' . $uniqId . '.ly ' . $uniqId . '.pdf'; $keyString = 'lilypond ' . $uniqId . '-key.ly ' . $uniqId . '-key.pdf'; exec($testString, $output); exec($keyString, $output); unlink($uniqId . '.ly'); unlink($uniqId . '-key.ly'); return ['id' => $uniqId]; }
/** * Get the output of the body. * * @access public * @param string $type - Either Command::HTML or Command::TEXT * @param mixed $body * @return string */ public function getOutput($type, $body) { $command = new CommandBuilder($this->command); $tempFileName = $this->getTmpFile($body); //Set output type to $type $command->addArgument('mode', $type); //Add temporary file as parameter $command->addParam($tempFileName); $shell = new Exec(); $shell->run($command); unlink($tempFileName); return implode("\n", $shell->getOutput()); }
public function testEmptyArgument() { $command = new Command('ls'); $command->addArgument('test'); $this->assertEquals("ls --test", (string) $command, 'Empty arguments should be allowed'); }