in reply to Running speedtest-cli with Perl and cron

The capture group in the regex is missing an open paren, e.g. /Download\:([0-9\.]*)/ (although I might suggest something like /Download:\s*(\S+)/ to make it a little bit more flexible if the program's output varies). You say it works on AIX, I'm a little unsure how that's possible...

On Ubuntu, is cron emailing any error messages to the crontab's user? What error messages do you get running this from the command line (not from the crontab)?

You really should be using warnings and strict!

Also, there are modules that can help you capture the output of external programs, such as Capture::Tiny, IPC::System::Simple or IPC::Run3.

You can either have the script write to an output file, or do it from the crontab using shell redirection - in either case you can append to the output file using >> instead of >.

Replies are listed 'Best First'.
Re^2: Running speedtest-cli with Perl and cron
by ethered (Initiate) on Dec 12, 2014 at 06:41 UTC
    Yes! Your suggestion for the if-statement works like a charm!

    The script ran just as it should before as well, it just didn't give me the results from the test. Which is strange because it did so on the AIX system at work. The only thing not printing to screen is the up/down values.

    Since I started mucking around with Perl only days ago I'm not very aware of how to really do stuff. I will definitely look into warnings and strict, and perhaps look for a smarter way of building it without the if-elsif.

    Thanks for the help! :-)

    Oh, btw... Here's the output using your statements:

    Fri Dec 12 07:30:00 2014 : Download 47.82 Fri Dec 12 07:30:00 2014 : Upload 10.28