Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

Perl script on windows node

by kaka_2 (Acolyte)
on Apr 03, 2012 at 08:08 UTC ( #963189=perlquestion: print w/ replies, xml ) Need Help??
kaka_2 has asked for the wisdom of the Perl Monks concerning the following question:

Hi Experts, I am into monitroing solution and good with shell scrpting but perl is just new to me. i am looking for a help from you guys. i need a perl script which run on windows server and do the following. 1. Check if a File abc was modified or not in last X minutes. if yes check next condition else action. 2. Check if the size of file is greater than XXX KB/MB/GB. if it not check next else action. Your help will really appriciated.

Comment on Perl script on windows node
Re: Perl script on windows node
by tobyink (Abbot) on Apr 03, 2012 at 08:22 UTC

    Read the perlfunc sections about "-X", "stat" and "time".

    use 5.010; use strict; my $modified_within = 60 * 5; # 5 minutes my $size_limit = 1024 * 1024 * 2; # 2 MB my $file = "/some/file/name"; if ([stat $file]->[9] > time - $modified_within) { if (-s $file > $size_limit) { say "File is recent, and over size limit"; } else { say "File is recent, but not over size limit"; } } else { say "File is not recent"; }
    perl -E'sub Monkey::do{say$_,for@_,do{($monkey=[caller(0)]->[3])=~s{::}{ }and$monkey}}"Monkey say"->Monkey::do'
      Hi Tobyink, First of all thanks for taking time and writing the codes. i have perl v 5.8 installed on my server which comes with the application itself and when i execute the script it says it require 5.10 and fails during compilation. Is it possible to make it work with the version i have? Thank You. KAKA

        say() is the only feature being used from 5.10, so all you need to do is replace all instances of 'say' with 'print'. To keep the output the same, add a newline character (\n) to the end of each quoted string you are printing out.

        EDIT: As pointed out by ww, I should have explicitly stated that along with replacing say with print, the 'use 5.10' line should be removed as well. Thanks!

Re: Perl script on windows node
by nikosv (Hermit) on Apr 03, 2012 at 19:16 UTC

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://963189]
Approved by Corion
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others exploiting the Monastery: (8)
As of 2014-07-22 07:39 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite superfluous repetitious redundant duplicative phrase is:









    Results (106 votes), past polls