Skip to content
Snippets Groups Projects
Commit 4c7b5746 authored by Hahn Axel (hahn)'s avatar Hahn Axel (hahn)
Browse files

workaround for ms windows dowload with wget

parent a3719928
No related branches found
No related tags found
No related merge requests found
...@@ -64,57 +64,57 @@ function _chdir(string $sDir): void ...@@ -64,57 +64,57 @@ function _chdir(string $sDir): void
* *
* @return int * @return int
*/ */
function _exec(string $cmd, bool $bAbortOnError=true): int function _exec(string $cmd, bool $bAbortOnError=true, $bForceExec=false): int
{ {
global $aCol; global $aCol;
echo "$aCol[blue]cmd > $cmd$aCol[reset]\n"; echo "$aCol[blue]cmd > $cmd$aCol[reset]\n";
$iStart=microtime(true); $iStart=microtime(true);
/* if($bForceExec) {
exec("$cmd 2>&1", $aOut, $rc); exec("$cmd 2>&1", $aOut, $rc);
$iEnd=microtime(true);
if (!count($aOut)) {
$aOut = ["-- no output --"];
}
echo implode("\n", $aOut) . "\n";
*/
// show output in real-time
$descriptorspec = [
0 => ["pipe", "r"], // stdin
1 => ["pipe", "w"], // stdout
2 => ["pipe", "w"] // stderr
];
$process = proc_open($cmd, $descriptorspec, $pipes);
if (is_resource($process)) {
// Close stdin pipe
fclose($pipes[0]);
// Read stdout and stderr in real-time
while ($output = fgets($pipes[1])) {
echo " | $output";
flush();
}
fclose($pipes[1]);
while ($error = fgets($pipes[2])) {
echo " 2| $error";
flush();
}
fclose($pipes[2]);
// Close the process
$rc=proc_close($process);
$iEnd=microtime(true); $iEnd=microtime(true);
if (!count($aOut)) {
$aOut = ["-- no output --"];
}
echo implode("\n", $aOut) . "\n";
} else { } else {
if($bAbortOnError){
_abort("Unable to execute command."); // show output in real-time
$descriptorspec = [
0 => ["pipe", "r"], // stdin
1 => ["pipe", "w"], // stdout
2 => ["pipe", "w"] // stderr
];
$process = proc_open($cmd, $descriptorspec, $pipes);
if (is_resource($process)) {
// Close stdin pipe
fclose($pipes[0]);
// Read stdout and stderr in real-time
while ($output = fgets($pipes[1])) {
echo " | $output";
flush();
}
fclose($pipes[1]);
while ($error = fgets($pipes[2])) {
echo " 2| $error";
flush();
}
fclose($pipes[2]);
// Close the process
$rc=proc_close($process);
$iEnd=microtime(true);
} else {
if($bAbortOnError){
_abort("Unable to execute command.");
}
_skip("Unable to execute command.");
} }
_skip("Unable to execute command.");
} }
$sTime= "... ⏱️ Time: " . round($iEnd-$iStart, 3) . "s\n"; $sTime= "... ⏱️ Time: " . round($iEnd-$iStart, 3) . "s\n";
if ($rc != 0) { if ($rc != 0) {
......
...@@ -163,7 +163,7 @@ _exec("php -l \"$incfile\""); ...@@ -163,7 +163,7 @@ _exec("php -l \"$incfile\"");
_h1("Get / update spc"); _h1("Get / update spc");
_chdir("$selfdir/$dirExternal/bin"); _chdir("$selfdir/$dirExternal/bin");
if(!file_exists($SPC)){ if(!file_exists($SPC)){
_exec("wget -O $SPC \"$spcUrl\""); _exec("wget -O $SPC \"$spcUrl\"", true, ($myos == "windows"));
} else { } else {
_skip("download of spc."); _skip("download of spc.");
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment