views:

86

answers:

1

Hi Guys,

I am trying to create my own web interface for the plowshare utility, managed to get the script running okay so far, but I am a bit unsatisfied by the way the results are being displayed. Currently I am loading the text file into an array and display it and refresh the page from time to time to load the new results. The text file is being updated by the plowshare utility. I've been working my brain to death for the past 2 days but can't figure out how I can make this work.

So ... my problem, I have the below log file, and I would like to extract the following information from it:

Filename Size Procent Speed

To make it more interesting the log file is not always in the current form, it fills up along the away, so the script has to take that under consideration.

If anyone can give me some pointers on this one will be greatly apreciated. Php or shell script should be ok

Thanks, Cristian.

start download (megaupload): http://www.megaupload.com/?d=i6garixs
Downloading waiting page (loop 1)
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
100 13238    0 13238    0     0  20853      0 --:--:-- --:--:-- --:--:-- 27636
100 33268    0 33268    0     0  42955      0 --:--:-- --:--:-- --:--:-- 53831
captcha URL: http://wwwq41.megaupload.com/gencap.php?ef1b05e85685f16d.gif
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
100   776  100   776    0     0   2169      0 --:--:-- --:--:-- --:--:--  5705
100   776  100   776    0     0   2163      0 --:--:-- --:--:-- --:--:--  5664
Install aview or libcaca to display captcha image
Tesseract Open Source OCR Engine
Decoded captcha: XFA6
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
153  1186    0  1186    0   634   2366   1265 --:--:-- --:--:-- --:--:--  3417
102 33268    0 33268    0   634  37143    707 --:--:-- --:--:-- --:--:-- 44896
Wrong captcha
Downloading waiting page (loop 2)
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
100 13238    0 13238    0     0  22979      0 --:--:-- --:--:-- --:--:-- 31444
100 33268    0 33268    0     0  46924      0 --:--:-- --:--:-- --:--:-- 60050
captcha URL: http://wwwq41.megaupload.com/gencap.php?b71b011cbdab7bfc.gif
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
100   794  100   794    0     0   2647      0 --:--:-- --:--:-- --:--:--  5838
100   794  100   794    0     0   2637      0 --:--:-- --:--:-- --:--:--  5795
Install aview or libcaca to display captcha image
Tesseract Open Source OCR Engine
Decoded captcha: FGN6
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
102 29302    0 29302    0   634  41305    893 --:--:-- --:--:-- --:--:-- 53083
101 36366    0 36366    0   634  51120    891 --:--:-- --:--:-- --:--:-- 65642
Waiting 47 seconds... 37.. 27.. 17.. 7.. 0
File URL: http://www738.megaupload.com/files/f65bd851b6f2ae1e1a39d43180d59517/ebay_yearmix_2008_revs.zip
Filename: ebay_yearmix_2008_revs.zip
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
  0     0    0     0    0     0      0      0 --:--:--  0:00:01 --:--:--     0
  0     0    0     0    0     0      0      0 --:--:--  0:00:02 --:--:--     0
  0  127M    0  1070    0     0    407      0 91:24:14  0:00:02 91:24:12   448
  0  127M    0  155k    0     0  44465      0  0:50:11  0:00:03  0:50:08 47661
  0  127M    0  949k    0     0   203k      0  0:10:41  0:00:04  0:10:37  215k
  1  127M    1 1330k    0     0   237k      0  0:09:10  0:00:05  0:09:05  306k
  1  127M    1 2401k    0     0   363k      0  0:05:59  0:00:06  0:05:53  553k
  2  127M    2 3247k    0     0   429k      0  0:05:04  0:00:07  0:04:57  658k
  3  127M    3 4668k    0     0   545k      0  0:03:59  0:00:08  0:03:51  905k
  4  127M    4 5948k    0     0   621k      0  0:03:30  0:00:09  0:03:21 1016k
  5  127M    5 6978k    0     0   660k      0  0:03:17  0:00:10  0:03:07 1137k
  6  127M    6 8169k    0     0   707k      0  0:03:04  0:00:11  0:02:53 1164k
  7  127M    7 9354k    0     0   743k      0  0:02:55  0:00:12  0:02:43 1217k
  7  127M    7 10.0M    0     0   754k      0  0:02:53  0:00:13  0:02:40 1110k
  8  127M    8 10.9M    0     0   769k      0  0:02:49  0:00:14  0:02:35 1054k
  9  127M    9 12.0M    0     0   794k      0  0:02:44  0:00:15  0:02:29 1077k
 10  127M   10 13.2M    0     0   818k      0  0:02:39  0:00:16  0:02:23 1074k
 11  127M   11 14.3M    0     0   837k      0  0:02:36  0:00:17  0:02:19 1072k
 12  127M   12 15.5M    0     0   856k      0  0:02:32  0:00:18  0:02:14 1138k
 13  127M   13 16.7M    0     0   875k      0  0:02:29  0:00:19  0:02:10 1184k
 14  127M   14 17.9M    0     0   891k      0  0:02:26  0:00:20  0:02:06 1193k
 15  127M   15 19.2M    0     0   912k      0  0:02:23  0:00:21  0:02:02 1224k
 16  127M   16 20.7M    0     0   941k      0  0:02:18  0:00:22  0:01:56 1309k
 17  127M   17 22.4M    0     0   975k      0  0:02:14  0:00:23  0:01:51 1414k
 19  127M   19 24.5M    0     0  1022k      0  0:02:07  0:00:24  0:01:43 1600k
 20  127M   20 26.2M    0     0  1052k      0  0:02:04  0:00:25  0:01:39 1716k
 22  127M   22 28.3M    0     0  1094k      0  0:01:59  0:00:26  0:01:33 1878k
 24  127M   24 30.6M    0     0  1139k      0  0:01:54  0:00:27  0:01:27 2031k
 25  127M   25 33.0M    0     0  1184k      0  0:01:50  0:00:28  0:01:22 2171k
 27  127M   27 35.6M    0     0  1234k      0  0:01:45  0:00:29  0:01:16 2272k
 29  127M   29 38.0M    0     0  1274k      0  0:01:42  0:00:30  0:01:12 2409k
 30  127M   30 39.2M    0     0  1271k      0  0:01:42  0:00:31  0:01:11 2212k
 31  127M   31 40.5M    0     0  1273k      0  0:01:42  0:00:32  0:01:10 2009k
 32  127M   32 41.6M    0     0  1269k      0  0:01:42  0:00:33  0:01:09 1755k
 33  127M   33 42.7M    0     0  1266k      0  0:01:43  0:00:34  0:01:09 1455k
 34  127M   34 43.9M    0     0  1266k      0  0:01:43  0:00:35  0:01:08 1219k
 35  127M   35 45.1M    0     0  1266k      0  0:01:43  0:00:36  0:01:07 1229k
 36  127M   36 46.4M    0     0  1265k      0  0:01:43  0:00:37  0:01:06 1212k
 37  127M   37 47.7M    0     0  1266k      0  0:01:43  0:00:38  0:01:05 1246k
 38  127M   38 48.9M    0     0  1267k      0  0:01:43  0:00:39  0:01:04 1272k
 39  127M   39 50.2M    0     0  1269k      0  0:01:43  0:00:40  0:01:03 1286k
 40  127M   40 51.8M    0     0  1277k      0  0:01:42  0:00:41  0:01:01 1357k
 41  127M   41 53.5M    0     0  1287k      0  0:01:41  0:00:42  0:00:59 1455k
 43  127M   43 55.5M    0     0  1306k      0  0:01:40  0:00:43  0:00:57 1613k
 44  127M   44 57.2M    0     0  1314k      0  0:01:39  0:00:44  0:00:55 1685k
 45  127M   45 57.5M    0     0  1293k      0  0:01:41  0:00:45  0:00:56 1489k
 45  127M   45 58.4M    0     0  1286k      0  0:01:41  0:00:46  0:00:55 1367k
 46  127M   46 59.4M    0     0  1279k      0  0:01:42  0:00:47  0:00:55 1210k
 47  127M   47 60.4M    0     0  1275k      0  0:01:42  0:00:48  0:00:54 1008k
 48  127M   48 61.6M    0     0  1273k      0  0:01:42  0:00:49  0:00:53  908k
 49  127M   49 62.7M    0     0  1270k      0  0:01:42  0:00:50  0:00:52 1057k
 49  127M   49 63.7M    0     0  1266k      0  0:01:43  0:00:51  0:00:52 1076k
 50  127M   50 64.9M    0     0  1265k      0  0:01:43  0:00:52  0:00:51 1126k
 51  127M   51 66.1M    0     0  1264k      0  0:01:43  0:00:53  0:00:50 1154k
 52  127M   52 67.4M    0     0  1266k      0  0:01:43  0:00:54  0:00:49 1190k
 54  127M   54 69.1M    0     0  1274k      0  0:01:42  0:00:55  0:00:47 1319k
 55  127M   55 71.1M    0     0  1288k      0  0:01:41  0:00:56  0:00:45 1520k
 57  127M   57 73.1M    0     0  1301k      0  0:01:40  0:00:57  0:00:43 1684k
 58  127M   58 75.2M    0     0  1315k      0  0:01:39  0:00:58  0:00:41 1858k
 60  127M   60 77.5M    0     0  1333k      0  0:01:38  0:00:59  0:00:39 2067k
 62  127M   62 79.8M    0     0  1350k      0  0:01:36  0:01:00  0:00:36 2198k
 64  127M   64 82.0M    0     0  1365k      0  0:01:35  0:01:01  0:00:34 2229k
 65  127M   65 83.9M    0     0  1374k      0  0:01:35  0:01:02  0:00:33 2205k
 67  127M   67 85.9M    0     0  1384k      0  0:01:34  0:01:03  0:00:31 2197k
 68  127M   68 87.9M    0     0  1395k      0  0:01:33  0:01:04  0:00:29 2138k
 70  127M   70 90.1M    0     0  1408k      0  0:01:32  0:01:05  0:00:27 2110k
 72  127M   72 92.2M    0     0  1419k      0  0:01:32  0:01:06  0:00:26 2085k
 73  127M   73 94.3M    0     0  1430k      0  0:01:31  0:01:07  0:00:24 2140k
 75  127M   75 96.5M    0     0  1442k      0  0:01:30  0:01:08  0:00:22 2182k
 77  127M   77 98.8M    0     0  1454k      0  0:01:29  0:01:09  0:00:20 2212k
 79  127M   79  101M    0     0  1467k      0  0:01:29  0:01:10  0:00:19 2240k
 80  127M   80  102M    0     0  1467k      0  0:01:29  0:01:11  0:00:18 2108k
 81  127M   81  103M    0     0  1459k      0  0:01:29  0:01:12  0:00:17 1856k
 81  127M   81  104M    0     0  1452k      0  0:01:30  0:01:13  0:00:17 1579k
 82  127M   82  105M    0     0  1442k      0  0:01:30  0:01:14  0:00:16 1280k
 82  127M   82  105M    0     0  1435k      0  0:01:31  0:01:15  0:00:16  978k
 83  127M   83  106M    0     0  1428k      0  0:01:31  0:01:16  0:00:15  856k
 84  127M   84  107M    0     0  1420k      0  0:01:32  0:01:17  0:00:15  852k
 84  127M   84  108M    0     0  1414k      0  0:01:32  0:01:18  0:00:14  859k
 85  127M   85  109M    0     0  1411k      0  0:01:32  0:01:19  0:00:13  933k
 86  127M   86  110M    0     0  1409k      0  0:01:32  0:01:20  0:00:12 1025k
 88  127M   88  112M    0     0  1412k      0  0:01:32  0:01:21  0:00:11 1171k
 89  127M   89  114M    0     0  1422k      0  0:01:31  0:01:22  0:00:09 1447k
 91  127M   91  117M    0     0  1435k      0  0:01:31  0:01:23  0:00:08 1767k
 92  127M   92  118M    0     0  1434k      0  0:01:31  0:01:24  0:00:07 1802k
 93  127M   93  119M    0     0  1431k      0  0:01:31  0:01:25  0:00:06 1773k
 94  127M   94  120M    0     0  1428k      0  0:01:31  0:01:26  0:00:05 1683k
 95  127M   95  121M    0     0  1425k      0  0:01:31  0:01:27  0:00:04 1482k
 96  127M   96  123M    0     0  1424k      0  0:01:31  0:01:28  0:00:03 1232k
 97  127M   97  124M    0     0  1422k      0  0:01:31  0:01:29  0:00:02 1224k
 98  127M   98  125M    0     0  1420k      0  0:01:32  0:01:30  0:00:02 1236k
 99  127M   99  126M    0     0  1419k      0  0:01:32  0:01:31  0:00:01 1260k
100  127M  100  127M    0     0  1419k      0  0:01:32  0:01:32 --:--:-- 1289k
+1  A: 

This looks tab separated so you can use fgetcsv to parse it. Just provide a tab as the delimiter. Will still be quite difficult to make sense of it then, but it's a start.

Gordon
I'll have a look. Thx,C.
Chris19
I tried using the fgetcsv command but with little chances of success. the way the informaiton is being parsed is distorted, the columns are not being respected by the fgetcsv command. I used the script available on php page.
Chris19
@Chris I told you it would still be difficult. The content you show is not too parseable for machines. You will do have a lot of post processing. If the columns are not respected, make sure you are actually using the correct delimiter. I am only assuming it's a tab stop. They might be spaces and well (which would complicate things even more). It's a start, nothing more.
Gordon
@Gordon, Thanks for your help, first of all. I checked the script to see if is using the correct delimiter, made a few small adjustments and got pretty much the same result. I'll keep trying, at the moment I'll just leave it as it is due to lack of the time and maybe inspiration as well :). Cheers,C.
Chris19