N
N
Nikolai Novosad2015-12-22 23:08:38
linux
Nikolai Novosad, 2015-12-22 23:08:38

System not returning last line of output?

Hello.
When executed in a script

$result_load = system("/usr/bin/wget -i $from -nH -r --cut-dirs=2 --directory-prefix=$to -nc");

does not return the last line of the output.
var_dump($result_load);
or if
$result_load = system("/usr/bin/wget -i $from -nH -r --cut-dirs=2 --directory-prefix=$to -nc", $output);
var_dump($output);

always returns string(0) "" .
But judging by the documentation , this should not be the case.
Wget works as it should, but it needs a type check if the result is != null, then show a message that everything is fine.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
C
CycaHuH, 2015-12-23
@CycaHuH

system returns output from stdout, while wget writes to stderr.
One could redirect output from stderr to stdout like so:
but the interpreter escapes special characters.
Worth a look in the direction popen

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question