Script to capture date/time in seconds in PERL... Cant understand errors


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Script to capture date/time in seconds in PERL... Cant understand errors
# 1  
Old 06-10-2010
Script to capture date/time in seconds in PERL... Cant understand errors

I'm Using this script to find the time of a file. I'm very much new to PERL
and found this script posted by some one on this forum.
It runs perfectly fine, just that it gives me following errors with the
accurate output as well. I jus want the output to be stored in another file
so that i can later use it for my calculations...

PERL SCRIPT THAT I'M USING
Code:
#!/usr/contrib/bin/perl
#^###################################################################
#^ $Header: inodetime.pl,v  1.1 97/01/20 10:17:00 http srvr? $
#^###################################################################
#^ -------------------
#^ This program prints the modification times and names of files.
#^ It uses the following format:  inodetime.pl filename
#^ It will accept:  inodetime.pl  filename1 filename2 filename3
#^                  inodetime.pl  /tmp/file*
#^ The format of the output is: YYYYMMDDhhmmss filename
#^ example:
#^           $ inodetime.pl  /tmp/t*
#^           19961115105425 /tmp/test.sql
#^           19970116113616 /tmp/tststat.pl
#^
#^ TRICK To Remember The Program Name
#^ ----------------------------------
#^     inodetime == I No De Time
#^     ^^ ^ ^
#^                                                                KSG
#^###################################################################

############################################
# Get the (next) input from the command line
############################################
while ($curfile = $ARGV[0])
{
   #################################################
   # Do following code block only if $curfile exists
   #################################################
   if (-e $curfile)
   {
      ###############################
      # stat structure into variables
      ###############################
      ($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,
      $atime,$mtime,$ctime,$blksize,$blocks)
      = stat("$curfile");
      ###############################
      # time structure into variables
      ###############################
      local($sec,$min,$hr,$day,$mon,$yr,$wday,@dntcare) =
localtime($mtime);
      $yr = ($yr>=70) ? $yr+1900 : $yr+2000;
      $yr="$yr";
      $mon = (++$mon < 10) ? "0$mon" : "$mon";
      $day = ($day < 10) ? "0$day" : "$day";
      $hr  = ($hr < 10) ? "0$hr" : "$hr";
      $min = ($min < 10) ? "0$min" : "$min";
      $sec = ($sec < 10) ? "0$sec" : "$sec";
      ##################################################################
      # Rearrange in the YYYYMMDDhhmmss format and assign to $dte  variable
      ##################################################################
      $dte = join('',$yr,$mon,$day,$hr,$min,$sec);
      ######################################
      # Print modification date and filename
      ######################################

      print ("$dte $curfile\n");
      }
   ########################################
   # Shift to next position in command line
   ########################################
   shift (@ARGV);
}


#~###################################################################
#~###################################################################
#~
#~ $Log:        inodetime.pl,v  $
#~ Revision 1.1  97/01/20  10:17:00  10:17:00  http ()
#~ reversed output
#~ from: filename date
#~ to:   date filename
#~
#~ Revision 1.0  97/01/17  12:37:32  12:37:32  http ()
#~ Initial revision
#~
#~###################################################################
#~###################################################################

Errors occured:

Code:
Name "main::dntcare" used only once: possible typo at inodetime.pl line 42.
Name "main::mode" used only once: possible typo at inodetime.pl line 36.
Name "main::ino" used only once: possible typo at inodetime.pl line 36.
Name "main::rdev" used only once: possible typo at inodetime.pl line 36.
Name "main::blksize" used only once: possible typo at inodetime.pl line 37.
Name "main::gid" used only once: possible typo at inodetime.pl line 36.
Name "main::size" used only once: possible typo at inodetime.pl line 36.
Name "main::nlink" used only once: possible typo at inodetime.pl line 36.
Name "main::dev" used only once: possible typo at inodetime.pl line 36.
Name "main::uid" used only once: possible typo at inodetime.pl line 36.
Name "main::atime" used only once: possible typo at inodetime.pl line 37.
Name "main::ctime" used only once: possible typo at inodetime.pl line 37.
Name "main::wday" used only once: possible typo at inodetime.pl line 42.
Name "main::blocks" used only once: possible typo at inodetime.pl line 37.
20100430070935 update.sh             <----     CORRECT OUTPUT...

I dont understand the errors...
Any kind of help is appreciated.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Programming

Please help me understand errors in perl program

co #! /usr/bin/perl use strict; use warnings; use diagnostics; my $amount=""; my $bain; ; my $code=""; my $date;my $day;my $line; my $mo; my $LNUM = 0; my $xyz=""; my $yr; $yr = 2015; my $F; my @F; while (<>) { chop; ++$LNUM; @F = split(';'); if ( $F eq "Date" )... (1 Reply)
Discussion started by: hpk
1 Replies

2. Shell Programming and Scripting

Shell script to capture Current day ORA errors from Alert Log

Please provide Shell script to capture ORA errors from Alert Log for a given date or Current date. -Veera (1 Reply)
Discussion started by: Veera_V
1 Replies

3. Shell Programming and Scripting

Perl:Script to append date and time stamp

Help with Perl script : I have a web.xml file with a line <display-name>some_text_here</display-name> Need to append the current date and time stamp to the string and save the XML file Something like <display-name>some_text_here._01_23_2014_03_56_33</display-name> -->Finally want... (5 Replies)
Discussion started by: gaurav99
5 Replies

4. Shell Programming and Scripting

Need to capture dates between start date and end date Using perl.

Hi All, Want to get all dates and Julian week number for that date between the start date and end date. How can I achive this using perl? (To achive above functionality, I was connecting to the database from DB server. Need to execute the same script in application server, since databse... (6 Replies)
Discussion started by: Nagaraja Akkiva
6 Replies

5. Shell Programming and Scripting

Shell script to capture ORA errors from Alert Log

Hi, as the title says, I am after a simple script, which will open the Alert log from an 11.2.0.1 Linux environment and mail the error message and description to a recipient email address. I can then schedule this job via cron and let it run every 15 minutes. I have searched online... (16 Replies)
Discussion started by: jnrpeardba
16 Replies

6. Shell Programming and Scripting

Capture makefile errors in shell script

Hi, I have a bash script which calls a few "make". I would like to know whether the makefile failed with any errors. How do I do that in the script? Thanks, S (2 Replies)
Discussion started by: suryaemlinux
2 Replies

7. Shell Programming and Scripting

Get Current Time in Seconds Perl

hi guys, i need to know how to get the current date/time in seconds and i want to be able to do this in a one liner. like say for instance, if want to get what the time is right now, i'll issue a command like this: ## perl -e ' print scalar(localtime(time + 0)), "\n"' Tue Jul 13 17:45:50... (4 Replies)
Discussion started by: SkySmart
4 Replies

8. Programming

Date time problem while executing perl script.

Hi All, This Monday 15th March 2010, i have faced a weired issue with my Perl script execution, this script is scheduled to run at 1 minute past midnight on daily basis ( 00:01 EST ) generally for fetching previous business date , say if it is Monday it should give last Friday date, for Tuesday... (0 Replies)
Discussion started by: ravimishra
0 Replies

9. Shell Programming and Scripting

Script to capture errors

Hello; I'm trying to write a script to capture any hardware error from logs/syslog on my SUSE 10 servers so i can be notified if we have any hardware issues such a bad fan or battery, etc.. Thanks in advance for any help (2 Replies)
Discussion started by: Katkota
2 Replies

10. AIX

Unable to display the date-time in seconds on AIX

Hi, In unix the command "date +%s" displays the date-time in seconds since ‚00:00:00 1970-01-01 UTC‚ (a GNU extension) when executed on unix: -sh-2.05b$ date +%s 1152092690 I tried with all the format control output but unable to display the date-time in seconds i,e as in unix format. Can... (6 Replies)
Discussion started by: me_haroon
6 Replies
Login or Register to Ask a Question

Featured Tech Videos