PHP exec abbreviates and cut output made by unbuffer?

Hi all,

I try to catch and save in a log file the output of LFTP using unbuffer, because seems impossible to get it via other ways, namely the usual > logfile.txt

Certainly the format shown in the shell is what I prefer because other dialogs (like using --log= or
xfer:log-file) don’t show the information about the progress so good as is shown in the shell.

Let me show you all the line I’m using …

unbuffer lftp -e “set ssl:verify-certificate no; set ftp:ssl-protect-data yes; set ftp:ssl-protect-list yes; mirror --reverse /path/to/send folder_to_receive_files ; quit” -u,password > mylog.log 2>&1

In the shell (I’m using Ubuntu) and using unbuffer I get the output well …

[code]mkdir folder_to_receive_files' [Connecting...] mkdir folder_to_receive_files’ [Waiting for response…]

Transferring file OctoCod_1920x1080_Hitman.hevc.good.mp4' OctoCod_1920x1080_Hitman.hevc.good.mp4’ at 0 (0%) [Waiting for response…]
OctoCod_1920x1080_Hitman.hevc.good.mp4' at 76744 (0%) [Sending data] OctoCod_1920x1080_Hitman.hevc.good.mp4’ at 608160 (2%) 397.4K/s eta:58s [Sending data]
… etc …[/code]

BUT this is the problem!! …

Passing above set of LFTP commands through PHP exec, namely exec('unbuffer lftp -e "set ssl:verify-certificate no; set… etc, etc);

I cannot get the right dialog, but I get a cut version of the full dialog, like that …

mkdir `folder_to_receive_files' [Connecting...] mkdir `folder_to_receive_files' [Waiting for response...] `...d_1920x1080_Hitman.hevc.mp4' at 0 (0%) [Waiting for response...] `...d_1920x1080_Hitman.hevc.mp4' at 125976 (0%) [Sending data] `...d_1920x1080_Hitman.hevc.mp4' at 660288 (2%) 431.4K/s eta:63s [Sending data] `...d_1920x1080_Hitman.hevc.mp4' at 1211976 (4%) 492.7K/s eta:54s [Sending data `...d_1920x1080_Hitman.hevc.mp4' at 1785384 (6%) 579.6K/s eta:45s [Sending data `...d_1920x1080_Hitman.hevc.mp4' at 2358792 (8%) 607.8K/s eta:42s [Sending data `...d_1920x1080_Hitman.hevc.mp4' at 2932200 (10%) 619.6K/s eta:40s [Sending dat `...d_1920x1080_Hitman.hevc.mp4' at 3505608 (12%) 639.3K/s eta:38s [Sending dat `...d_1920x1080_Hitman.hevc.mp4' at 4079016 (14%) 634.0K/s eta:38s [Sending dat

It’s something strange and is making me crazy. I have been two full days fighting against this problem.

Anyone has some idea about what is happening?

Thank you very much in advance for your help.

So show us your code, for starters [censored, obviously, for passwords/servers etc].

The code is like that …

$command = 'unbuffer lftp -e "set ssl:verify-certificate no; set ftp:ssl-protect-data yes; set ftp:ssl-protect-list yes; mirror --reverse /path/to/send folder_to_receive_files ; quit" -u,password > mylog.log 2>&1'; exec($command);

Have you tried actually using the [FPHP]exec[/FPHP] optional parameters to capture?

Yes I used the other parameters of exec and I cannot capture anything, seems that LFTP doesn’t send to stdout and because of this, people has to use unbuffer from expect-dev packet (you know: apt-get install expect-dev)

Right, but since unbuffer sends to stdout, you should be able to capture unbuffer’s output using the optional parameter, as llong as you dont pipe the output into a file in your command.

As I mentioned, in the shell, unbuffer works well, but when is passed through PHP exec, shell_exec or system, the string are chunked.

OK I understand.

And … is it possible to write stdout from exec on-the-fly on some file? It’s because I will show the LFTP progress dialog in a web.

Yes, I got the output from exec without enabling the pipe and is chunked unfortunately.

Seems that in the moment that stdout from unbuffer goes through PHP, strings are cutting up, and I don’t know why!! :frowning:

Any help is welcome, indeed.

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.