PDA

Archiv verlassen und diese Seite im Standarddesign anzeigen : (Sonstige) - PHP Could not open Input file



darkness
20.07.2016, 07:08
Hallo,

folgendes Problem existiert bei einem Projekt an dem ich arbeite...

Aufbau ...

- .sh die checkt ob eine "Instanz" von einem Skript läuft ... Wenn ja passiert nichts wenn nicht wird eine neue Instanz erstellt
- Fuelphp Task "runner" der "endlos" läuft und so aussieht


$bin = 'php';
if(strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') $bin = 'E:/xampp/php/php.exe';

$oil_path = realpath(__DIR__.'../../../').'\oil';

foreach($query->as_object()->execute() as $foo)
{
$output = shell_exec($bin.' '.$oil_path.' refine liebe foo='.$foo->id);
\Cli::write($output);
}


Das Problem das Dingen schreibt immer Could not open input file: oil ins Log file (also die SH) ich weiß null wieso ...

Wenn ich den runner task über console ausführe läuft alles wie erwartet.

xmasta4000
20.07.2016, 08:31
Mach mal:

echo $bin.' '.$oil_path.' refine liebe foo='.$foo->id
über dem exec bzw. schau dir im Debugger an ob das alles stimmt.

Eventuell ist der \ bei "\oil" falsch unter Linux. Bin mir nicht sicher da ich nie PHP im Zusammenhang mit Windows verwendet habe.
Sollte heißen:

$oil_path = realpath(__DIR__.'../../../').'/oil';

jbs
20.07.2016, 08:35
$bin = 'php';
if(strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') $bin = 'E:/xampp/php/php.exe';
define('DS', DIRECTORY_SEPARATOR);

$oil_path = realpath(dirname(__FILE__).DS.'..'.DS.'..'.DS.'..' .DS).DS.'oil';
if($oil_path === FALSE) {
return '$oil_path not found...';
}

foreach($query->as_object()->execute() as $foo)
{
$output = shell_exec($bin.' '.$oil_path.' refine liebe foo='.$foo->id);
\Cli::write($output);
}


Versuchs mal damit. Ist zwar nicht schön, sollte seinen Zweck aber erfüllen.

Realpath gibt false zurück, wenn er Probleme hat, den Pfad aufzulösen oder die Ordnerrechte nicht stimmen.

Weitere Info in der PHP Doku:

The running script must have executable permissions on all directories in the hierarchy, otherwise realpath() will return FALSE.

Firecooler
20.07.2016, 11:00
nutzt du fastcgi im nginx?

prüf ob die fastcgi params im configs mitgeladen ist...