Hi all!

For some time now my internet connection have been unreliable to say the least. I'm paying for a 50/50 connection, but I'm seeing a steady 23/18 on average(mbps). As well as some pretty annoying latency issues... So! I want to monitor this over time, to build a waterproof case for myself.

I want to use speedtest-cli on my Ubuntu server, and by cron make it do a speedtest every 12 hours. After asking internet for advice I ended wanting to do this with Perl.

This is my script so far...
open speedtest,"speedtest-cli --simple |" or die "Cannot open speedtes +t"; $datestring = localtime(); while (<speedtest>) { if (/Download\:[0-9\.]*)/) { $speed=$1; print "$datestring : Download $speed +n"; } elsif (/Upload\:[0-9\.]*)/) { $speed=$1; print "$datestring : Upload $speed +n"; } }

...which works fine except for the fact that it doesn't print the results, rather just time/date and "Download"/"Upload".

It works like a charm on AIX, but not on Ubuntu. Why?

Also; I want to store this in one .txt file, and I'm thinking that I'll do that in my crontab. Would it store each result in a new line in that file or overwrite it? Any ideas on how to do this?

Thank you for any and all help regarding this :-) PS: I can verify that the script starts speedtest-cli, and that it prints out time/date.

In reply to Running speedtest-cli with Perl and cron by ethered

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.