Perl Script to check file date and size


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Perl Script to check file date and size
# 22  
Old 04-20-2010
This is what i get:

Code:
-bash-3.2$ od -bc file_check.pl

0000000 012 043 041 057 165 163 162 057 154 157 143 141 154 057 142 151

         \n   #   !   /   u   s   r   /   l   o   c   a   l   /   b   i

0000020 156 057 160 145 162 154 012 163 165 142 040 103 150 145 143 153

          n   /   p   e   r   l  \n   s   u   b       C   h   e   c   k

0000040 151 156 147 106 151 154 145 163 173 012 012 040 040 040 040 040

          i   n   g   F   i   l   e   s   {  \n  \n

0000060 040 044 164 157 144 141 171 040 075 040 164 151 155 145 073 012

              $   t   o   d   a   y       =       t   i   m   e   ;  \n

0000100 040 040 040 040 040 040 044 164 157 144 141 171 040 055 075 040

                                  $   t   o   d   a   y       -   =

0000120 044 164 157 144 141 171 040 045 040 070 066 064 060 060 073 040

          $   t   o   d   a   y       %       8   6   4   0   0   ;

0000140 040 012 040 040 040 040 040 040 044 162 145 164 165 162 156 137

             \n                           $   r   e   t   u   r   n   _

0000160 166 141 154 165 145 040 075 040 060 073 012 040 040 040 040 040

          v   a   l   u   e       =       0   ;  \n

0000200 040 040 040 040 040 040 040 040 040 040 040 040 040 040 040 040



0000220 040 040 040 040 040 040 040 040 040 040 040 040 040 040 040 043

                                                                      #

0000240 040 040 012 040 040 040 040 040 040 044 155 164 151 155 145 040

                 \n                           $   m   t   i   m   e

0000260 075 040 050 163 164 141 164 050 042 044 137 133 060 135 042 051

          =       (   s   t   a   t   (   "   $   _   [   0   ]   "   )

0000300 051 133 071 135 040 174 174 040 144 151 145 040 042 143 141 156

          )   [   9   ]       |   |       d   i   e       "   c   a   n

0000320 156 157 164 040 163 164 141 164 040 146 151 154 145 040 044 041

          n   o   t       s   t   a   t       f   i   l   e       $   !

0000340 042 073 040 040 012 040 040 040 040 040 040 044 163 151 172 145

          "   ;          \n                           $   s   i   z   e

0000360 040 075 040 040 050 163 164 141 164 050 042 044 137 133 060 135

              =           (   s   t   a   t   (   "   $   _   [   0   ]

0000400 042 051 051 133 067 135 073 040 040 043 040 163 151 172 145 040

          "   )   )   [   7   ]   ;           #       s   i   z   e

0000420 151 156 040 142 171 164 145 163 012 040 040 040 040 040 040 044

          i   n       b   y   t   e   s  \n                           $

0000440 157 153 040 075 040 042 156 157 164 040 157 153 042 073 012 040

          o   k       =       "   n   o   t       o   k   "   ;  \n

0000460 040 040 040 040 040 012 040 040 040 040 040 040 151 146 050 040

                             \n                           i   f   (

0000500 044 163 151 172 145 040 076 040 060 040 046 046 040 044 155 164

          $   s   i   z   e       >       0       &   &       $   m   t

0000520 151 155 145 040 076 075 040 044 164 157 144 141 171 040 051 012

          i   m   e       >   =       $   t   o   d   a   y       )  \n

0000540 040 040 040 040 040 040 173 012 040 040 040 040 040 040 040 040

                                  {  \n

0000560 040 040 040 040 044 157 153 040 075 040 042 157 153 042 073 040

                          $   o   k       =       "   o   k   "   ;

0000600 012 040 040 040 040 040 040 040 040 040 040 040 040 044 162 145

         \n                                                   $   r   e

0000620 164 165 162 156 137 166 141 154 165 145 040 075 040 061 073 040

          t   u   r   n   _   v   a   l   u   e       =       1   ;

0000640 040 040 040 040 040 040 040 040 040 040 012 040 040 040 040 040

                                                 \n

0000660 040 175 012 040 040 040 040 040 040 160 162 151 156 164 040 042

              }  \n                           p   r   i   n   t       "

0000700 044 137 133 060 135 040 151 163 040 044 157 153 134 156 042 073

          $   _   [   0   ]       i   s       $   o   k   \   n   "   ;

0000720 012 040 040 040 040 040 040 162 145 164 165 162 156 040 044 162

         \n                           r   e   t   u   r   n       $   r

0000740 145 164 165 162 156 137 166 141 154 165 145 073 012 175 012 012

          e   t   u   r   n   _   v   a   l   u   e   ;  \n   }  \n  \n

0000760 044 146 157 165 156 144 040 075 040 060 073 012 157 160 145 156

          $   f   o   u   n   d       =       0   ;  \n   o   p   e   n

0001000 144 151 162 040 050 104 111 122 110 116 104 114 054 040 042 057

          d   i   r       (   D   I   R   H   N   D   L   ,       "   /

0001020 163 155 142 057 143 145 156 164 055 142 162 153 055 160 157 163

          s   m   b   /   c   e   n   t   -   b   r   k   -   p   o   s

0001040 071 056 160 141 170 143 150 151 057 160 157 163 151 164 151 157

          9   .   p   a   x   c   h   i   /   p   o   s   i   t   i   o

0001060 156 163 145 162 166 145 162 062 042 051 040 174 174 040 040 144

          n   s   e   r   v   e   r   2   "   )       |   |           d

0001100 151 145 040 042 103 141 156 156 157 164 040 157 160 145 156 040

          i   e       "   C   a   n   n   o   t       o   p   e   n

0001120 144 151 162 145 143 164 157 162 171 040 044 041 042 073 012 100

          d   i   r   e   c   t   o   r   y       $   !   "   ;  \n   @

0001140 146 151 154 145 154 151 163 164 040 075 040 162 145 141 144 144

          f   i   l   e   l   i   s   t       =       r   e   a   d   d

0001160 151 162 040 050 104 111 122 110 116 104 114 051 073 012 143 154

          i   r       (   D   I   R   H   N   D   L   )   ;  \n   c   l

0001200 157 163 145 144 151 162 040 050 104 111 122 110 116 104 114 051

          o   s   e   d   i   r       (   D   I   R   H   N   D   L   )

0001220 073 012 012 146 157 162 145 141 143 150 040 044 146 151 154 145

          ;  \n  \n   f   o   r   e   a   c   h       $   f   i   l   e

0001240 156 141 155 145 040 050 040 100 146 151 154 145 154 151 163 164

          n   a   m   e       (       @   f   i   l   e   l   i   s   t

0001260 040 051 012 173 012 040 040 040 151 146 040 050 044 146 151 154

              )  \n   {  \n               i   f       (   $   f   i   l

0001300 145 156 141 155 145 040 075 176 040 057 164 170 164 044 057 051

          e   n   a   m   e       =   ~       /   t   x   t   $   /   )

0001320 012 040 040 040 173 012 040 040 040 040 040 044 146 157 165 156

         \n               {  \n                       $   f   o   u   n

0001340 144 040 174 075 040 103 150 145 143 153 151 156 147 106 151 154

          d       |   =       C   h   e   c   k   i   n   g   F   i   l

0001360 145 163 040 044 146 151 154 145 156 141 155 145 073 012 040 040

          e   s       $   f   i   l   e   n   a   m   e   ;  \n

0001400 040 175 012 175 012 160 162 151 156 164 040 042 162 145 164 165

              }  \n   }  \n   p   r   i   n   t       "   r   e   t   u

0001420 162 156 040 163 164 141 164 165 163 040 075 040 044 146 157 165

          r   n       s   t   a   t   u   s       =       $   f   o   u

0001440 156 144 134 156 042 073 012 012 145 170 151 164 040 060 073 012

          n   d   \   n   "   ;  \n  \n   e   x   i   t       0   ;  \n

0001460 012 012 012

         \n  \n  \n

0001463

-bash-3.2$

# 23  
Old 04-20-2010
Hmm... doesn't seem to be out of place. Your error messages point towards a mangled program file.

I'd suggest you to perform incremental testing.
1) fire up a 2nd terminal window (assuming you have one open already),
2) create a new Perl file in vim,
3) add just one command or line of code,
4) save the file in unix format,
5) run the Perl program from the 1st terminal window.

Repeat 3), 4), 5) till you encounter a problem or execute the entire program successfully.

tyler_durden
# 24  
Old 04-20-2010
Could this be related to wrong path or permissions?
# 25  
Old 04-20-2010
Quote:
Originally Posted by DallasT
Could this be related to wrong path or permissions?
No.

tyler_durden
# 26  
Old 04-20-2010
Has it worked for you on your host?
# 27  
Old 04-20-2010
Quote:
Originally Posted by DallasT
Has it worked for you on your host?
Yes it has. Although I don't quite understand why you'd want to know that. The problem is in your system, not mine. Because it is working on my system won't make it work on your system automatically.

You gotta find the problem on your system; not cross-check if it works on the systems other than yours!

tyler_durden

Last edited by durden_tyler; 04-20-2010 at 07:28 PM..
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Script to determine Date,TotalFile,total size of file based on date

I have file listed like below -rw-r--r--+ 1 test test 17M Nov 26 14:43 test1.gz -rw-r--r--+ 1 test test 0 Nov 26 14:44 test2.gz -rw-r--r--+ 1 test test 0 Nov 27 10:41 test3.gz -rw-r--r--+ 1 test test 244K Nov 27 10:41 test4.gz -rw-r--r--+ 1 test test 17M Nov 27 10:41 test5.gz I... (5 Replies)
Discussion started by: krish2014
5 Replies

2. UNIX for Dummies Questions & Answers

Script to check for file size and then sftp

noted down (44 Replies)
Discussion started by: mirwasim
44 Replies

3. Shell Programming and Scripting

Perl code to check date and check files in particular dir

Hi Experts, I am checking how to get day in Perl. If it is “Monday” I need to process…below is the pseudo code. Can you please prove the code for below condition. if (today=="Monday" ) { while (current_time LESS THAN 9:01 AM) ... (1 Reply)
Discussion started by: ajaypatil_am
1 Replies

4. Shell Programming and Scripting

Please help I want script to check filename, size and date in specify path.

Please help, I want script to check filename, size and date in specify path. I want output as: DATE: YYYYMMDD HH:MM ------------------------------------------------ fileA,filesize,yyyy mm dd HH:MM fileA,filesize,yyyy mm dd HH:MM fileA,filesize,yyyy mm dd HH:MM fileA,filesize,yyyy mm dd... (1 Reply)
Discussion started by: akeji
1 Replies

5. Shell Programming and Scripting

Script to check file system size

Dears, the output of this command df -h | tr -s ' ' | cut -f5 -d' ' is capacity 24% 0% 0% 0% 0% 1% 0% 24% 24% 0% 93% 1% (4 Replies)
Discussion started by: xxmasrawy
4 Replies

6. Windows & DOS: Issues & Discussions

Check the file size using Batch script in windows

Hi, I need to check the file size using a batch script. Pls advise. (0 Replies)
Discussion started by: krackjack
0 Replies

7. Shell Programming and Scripting

shell script to check file size greater than 50M

Hi All, OS:AIX 64 bits using korn shell. Requirement: shell script to check file size greater than 50M and send mail alert. Thanks for your time! Regards, (3 Replies)
Discussion started by: a1_win
3 Replies

8. Shell Programming and Scripting

unix script to check whether particular file exists and to find its size

I want to find the size of particular file exists in a particular directory and i wnt to zip it. In the below mentioned code it should check the MQ.log in the particular directory.Please correct my code so that it will check for particular MQ.log but i could not able to check whether the... (9 Replies)
Discussion started by: Balachandar
9 Replies

9. Shell Programming and Scripting

Perl FTP - check file size

The FTP perl module does not have any function which checks if the file downloaded is of size 0. Is there any way in perl to check while getting the files through FTP? Sometimes, there might be a problem with FTP and the downloaded file maybe of size 0. Hence, I would like to FTP that file... (1 Reply)
Discussion started by: rahulrathod
1 Replies

10. UNIX for Dummies Questions & Answers

file date check script

I am creating a KSH script and need to check the filedate against the system date. I can get the sys date w. date command, and I was able to get the filedate w. the awk command but when I compare them w. an if condition statement I get syntax error. Not sure what's wrong, and other suggestions on... (4 Replies)
Discussion started by: jaxconsultant
4 Replies
Login or Register to Ask a Question