How to find 1 day old file on Windows for Active Perl


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting How to find 1 day old file on Windows for Active Perl
# 1  
Old 02-20-2003
Data How to find 1 day old file on Windows for Active Perl

How to find 1 day old file on Windows for Active Perl?
Is there anyone know the method?
If UNIX or LINUX, we can use the "find ...". How to we do for Windows?
# 2  
Old 02-20-2003
I'm confused.. are you asking how to find a file using the Windows operating system or how to find a file using the Perl programming language?

If it's Windows, then which version?
# 3  
Old 02-20-2003
If you go to start-->find(or search if it's xp), you can choose advanced search, and specify x days ago.
If you are tring to do it through Perl, from Orielly's Learning Perl:
"The Perl operator -M returns the age in days since a file or filehandle has last been modified"
# 4  
Old 02-20-2003
Sorry for the confusion.
When we use Perl running in UNIX, we can use the below command to search the one day old file.
@Files = qx/find . -name '*' -mtime -1 -print/;

The problem I am facing now is I am trying to do the same thing but under Windows platform through Active Perl (window based).
I have tried using windows, but it seems the script will be very long because you need to capture the last date modified file and compare the date with current date.

Is there any other solutions?
It is much better if I can use 1 line of command like UNIX (eg. find) on the Window based Perl.

Thank you.Smilie
# 5  
Old 02-21-2003
I created a small perl script .. see if it works for you:

Code:
#!C:\Perl\bin\perl.exe
 use File::Find;
 my @oldFiles;
 print "Content-type: text/html\n\n";
 find(\&cleanup, "C:\/WINDOWS/Temp/");
 sub cleanup {
   my $daysOld = ((time - +(stat($_))[9]) / 86400);
   if (/\./ && $daysOld >= 1 && $daysOld < 2) {
      push(@oldFiles, $File::Find::name);
   }
 }
 print @oldFiles;

If you want to search an entire drive, replace C:\/WINDOWS/Temp/ with C:\\

References:

http://techupdate.zdnet.co.uk/story/...122110,00.html
http://techupdate.zdnet.co.uk/i/z/tu...inga110902.htm

http://www.xav.com/perl/lib/Pod/perlfunc.html#item_stat
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. AIX

Samba 3.6 on AIX 7.1 - Windows 10 Access to AIX file shares using Active Directory authentication

I am running AIX 7.1 and currently we have samba 3.6.25 installed on the server. As it stands some AIX folders are shared that can be accessed by certain Windows users. The problem is that since Windows 10 the guest feature no longer works so users have to manually type in their Windows login/pwd... (14 Replies)
Discussion started by: linuxsnake
14 Replies

2. Proxy Server

Solaris 11.1 login authenticate with windows active directory

Hi, is that possible to login to solaris 11.1 authenticate with windows active directory? the user id is created in the windows active directory. Environment: Solaris 11.1 Windows 2012 Active Directory (3 Replies)
Discussion started by: freshmeat
3 Replies

3. UNIX for Dummies Questions & Answers

Need help configuring Active Perl on Windows Vista.: Perl Scripting on Windows

Hi All, Need help configuring Active Perl on Windows Vista. I am trying to install Active Perl on Windows Vista. The version of Active Perl i am trying to install is : ActivePerl 5.10.1 Build 1006 After installing it through cmd, When i try to run perl -v to check the version, i get the... (2 Replies)
Discussion started by: Vabiosis
2 Replies

4. Shell Programming and Scripting

Script to find previous month last day minus one day timestamp

Hi All, I need to find the previous month last day minus one day, using shell script. Can you guys help me to do this. My Requirment is as below: Input for me will be 2000909(YYYYMM) I need the previous months last day minus 1 day timestamp. That is i need 2000908 months last day minus ... (3 Replies)
Discussion started by: girish.raos
3 Replies

5. Windows & DOS: Issues & Discussions

Windows Active Network Connection Override

Hi All, I use two Network Connections at work: Wireless and LAN. Wireless network has no limitations, but LAN internet has a web filter. I start a download using my Wireless conn. (At this point, LAN is disabled) But when I activate my LAN connection my download stops immediately. LAN... (4 Replies)
Discussion started by: kalavkalav
4 Replies

6. Solaris

Connect smbclient to an windows server 2003 with active directory

Hello everybody .. i want connect with smbclient to an windows server 2003 with active directory. Exist a version of samba that can do this? Thank you very much for your time. Good Luck :b: (3 Replies)
Discussion started by: enkei17
3 Replies

7. UNIX Desktop Questions & Answers

Active windows when pointed.

Ok now is one is a reall dummy question...:rolleyes: I'm using KDE 3.3 and I want to know if there are any way to set the option where when I point(a cursor) to a window that window becomes active. Juust as you have in Solaris. Thanks & regards, (1 Reply)
Discussion started by: rimser9
1 Replies

8. UNIX for Dummies Questions & Answers

How to find Day of the Week from the given date (Perl)?

How to find the Day of the Week of the given Date using perl? If I have a date in YYY--MM-DD format, how to find the DOW? Based on that, I need to find the following sunday. Pls help. (5 Replies)
Discussion started by: deepakwins
5 Replies

9. Solaris

Connecting Solaris 9 to Windows Active Directory

Hi Everyone, Is it possible to for Solaris 9 box to join a Windows 2000 Active Directory Domain using Samba 3.X. If so are there any How To's out there or does anyone have experience with this. I have successfully done it with RHEL 3. Things that I configured in REDHAt to get it to... (0 Replies)
Discussion started by: morphous
0 Replies

10. Shell Programming and Scripting

Write a shell script to find whether the first day of the month is a working day

Hi , I am relatively new to unix... Can u pls help me out to find out if the first day of the month is a working day ie from (Monday to Friday)...using Date and If clause in Korn shell.. This is very urgent. Thanks for ur help... (7 Replies)
Discussion started by: phani
7 Replies
Login or Register to Ask a Question