Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

Perl script on windows node

by kaka_2 (Sexton)
on Apr 03, 2012 at 08:08 UTC ( [id://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.

Replies are listed 'Best First'.
Re: Perl script on windows node
by tobyink (Canon) 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'
    A reply falls below the community's threshold of quality. You may see it by logging in.
Re: Perl script on windows node
by nikosv (Deacon) on Apr 03, 2012 at 19:16 UTC

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
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?Last hourOther CB clients
Other Users?
Others learning in the Monastery: (5)
As of 2024-04-19 23:22 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found