ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
First of all I'm not perl smart nor am I knowledgable in scripting. I downloaded a perl script for generating clamav stats, the author had not updated it in several years and told me to go ahead and do with it what I could. Through some outside help I got the script to semi-work, however, I get the below errors:
Use of uninitialized value in substitution (s///) at /usr/local/bin/clamstats.pl line 105.
Use of uninitialized value in concatenation (.) or string at /usr/local/bin/clamstats.pl line 106.
Use of uninitialized value in concatenation (.) or string at /usr/local/bin/clamstats.pl line 106.
Use of uninitialized value in concatenation (.) or string at /usr/local/bin/clamstats.pl line 106.
Use of uninitialized value in concatenation (.) or string at /usr/local/bin/clamstats.pl line 106.
Use of uninitialized value in split at /usr/local/bin/clamstats.pl line 108.
Use of uninitialized value in hash element at /usr/local/bin/clamstats.pl line 115.
Use of uninitialized value in hash element at /usr/local/bin/clamstats.pl line 116.
Use of uninitialized value in hash element at /usr/local/bin/clamstats.pl line 117.
Use of uninitialized value in hash element at /usr/local/bin/clamstats.pl line 118.
Use of uninitialized value in hash element at /usr/local/bin/clamstats.pl line 120.
Use of uninitialized value in hash element at /usr/local/bin/clamstats.pl line 122.
Use of uninitialized value in hash element at /usr/local/bin/clamstats.pl line 122.
Use of uninitialized value in hash element at /usr/local/bin/clamstats.pl line 124.
Use of uninitialized value in hash element at /usr/local/bin/clamstats.pl line 124.
Use of uninitialized value in hash element at /usr/local/bin/clamstats.pl line 125.
Use of uninitialized value in hash element at /usr/local/bin/clamstats.pl line 125.
Use of uninitialized value in hash element at /usr/local/bin/clamstats.pl line 49.
Use of uninitialized value in sprintf at /usr/local/bin/clamstats.pl line 49.
Use of uninitialized value in sprintf at /usr/local/bin/clamstats.pl line 49.
Argument "" isn't numeric in sprintf at /usr/local/bin/clamstats.pl line 317.
Use of uninitialized value in sprintf at /usr/local/bin/clamstats.pl line 53.
I see that I can't post attachments. The script is 3.1kb gzip'd, if someone would like to look at the whole script, please let me know.
quote:
Use of uninitialized value in substitution (s///) at /usr/local/bin/clamstats.pl line 105.
There's no substitution in your example code; I think you need to go back at least one line.
If the lines are co-dependent, prob means you are substituting an uninit value and then trying to use it in the first line you've shown us ie effectively a string cooncat. Notice how you get the same complaint 4 times for line 106, which has 4 string subst/concats in it.
$hourmax = $stats{hour}->{$hour} if ($stats{hour}->{$hour} > $hourmax);
$datemax = $stats{date}->{$date} if ($stats{date}->{$date} > $datemax);
$monthmax = $stats{month}->{$month} if ($stats{month}->{$month} > $monthmax);
$yearmax = $stats{year}->{$year} if ($stats{year}->{$year} > $yearmax);
}
Here is the output of running clamstats.pl > cstatsoutput.txt:
ClamAV Statistics
cpollock
--------------------------------------------------------
clamd last started Sat May 20 16:07:28 2006
--------------------------------------------------------
Statistics since
Last Database Update Tue May 30 16:11:24 2006
--------------------------------------------------------
Total viruses detected 92
Total Database Signatures 57,032
--------------------------------------------------------
5 FreshClam errors, last on Thu May 25 14:36:34 2006: Mirrors are not fully synchronized. Please try again later.
By Year ( . = 4 viruses )
--------------------------
: 92 .......................
It partially looks correct, however, the date fields are all wrong. If run from the command line, the errors in my first post are shown, if ran outputting to a txt file they are not. Again, I know absolutely nothing about perl scripts.
To capture all the output, treat it like a shell script ie capture stdout & stderr like this
yourscript >script.log 2>&1
Basically, the if() statement there is trying to parse a date string of some sort, but it's doing it wrong, hence the rest of the errors.
Are you sure you can't post the script as a script.txt attachment?
Consider e-mailing the clamstat author directly...
Hi -
I looked at your "clamstat.pl" script, and I don't see anything obviously wrong.
HOWEVER ...
I also see that the purpose of the script is to monitor Clam Antivirus logs. My script won't even start, because I don't have Clam installed, so the script isn't finding a Clam logs directory:
It looks like your problem is that clamstats is finding the logs ... but they aren't in the format the script is expecting. Hence the "Use of uninitialized value" error. Not surprising, since the script was written in 2004 - and Clam A/V has undoubtedly changed their logfile format since then.
SUGGESTION:
Why not contact the original author of Clamstat.pl directly? His blog (and an e-mail link) are here: http://weblog.infoworld.com/venezia/
I did back on 22 May when I couldn't get it to run right. His reply was:
I haven't updated that code in forever, so it's entirely possible
> that this is a parsing error caused by a new log format or something
> similar. If/when I have time I'll update the code. Alternatively, it
> should be relatively simple to modify it to your needs...
>
> -Paul
I know next to nothing about scripts, I've made several small bash scripts to do simple things but thats the extent of my expertise.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.