The UNIX and Linux Forums  


Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Problem with csh script rahulrathod Shell Programming and Scripting 4 02-21-2008 12:38 PM
script problem tdavenpo Shell Programming and Scripting 3 01-04-2006 04:07 PM
Problem starting a script from a 'main'-script Rakker UNIX for Dummies Questions & Answers 3 06-28-2005 09:12 AM
problem with a script Lestat Shell Programming and Scripting 4 06-13-2005 01:30 PM
problem with ftp script...please help vancouver_joe UNIX for Advanced & Expert Users 2 11-22-2001 07:47 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 07-31-2006
12yearold 12yearold is offline
Registered User
  
 

Join Date: Jul 2006
Posts: 22
Some problem with script.

guys i have a Script was not written by me... that delete a particular file once it ages 7 days...
never the less, the script is not working as planed...

can someone help me out?

@fields = split( /\./, $logname );

$_ = $fields[1]; # get roll over time

# $1 $2 $3
# Y Y Y Y M M D D
/(\d\d\d\d)(\d\d)(\d\d)/;

$year = $1 - 1900; <-----WHY 1900??
$month = $2 - 1; <----- one month back???
$day = $3;

$time_of_log = timelocal( 0, 0, 0, $day, $month, $year );

if ($time_of_log < $time_expired)
{
# delete file
$filename = $dirname . "/" . $logname;
unlink $filename;


ERROR received,

Use of uninitialized value in subtraction (-) at ./script line 81.
Use of uninitialized value in subtraction (-) at ./script line 82.
Month '-1' out of range 0..11 at ./script line 85


I don't understand some of the lines here... is there a software that would show you the output for each line? i think that would help tremendously!
  #2 (permalink)  
Old 07-31-2006
tayyabq8's Avatar
tayyabq8 tayyabq8 is offline Forum Advisor  
Moderator
  
 

Join Date: Nov 2004
Location: Bahrain
Posts: 579
Message deleted, wrong input.

Last edited by tayyabq8; 07-31-2006 at 09:28 AM..
  #3 (permalink)  
Old 07-31-2006
reborg's Avatar
reborg reborg is offline Forum Staff  
Administrator
  
 

Join Date: Mar 2005
Location: Ireland
Posts: 4,238
Actually, the assignment syntax in the script is correct, this is perl.
  #4 (permalink)  
Old 07-31-2006
tayyabq8's Avatar
tayyabq8 tayyabq8 is offline Forum Advisor  
Moderator
  
 

Join Date: Nov 2004
Location: Bahrain
Posts: 579
Oh sorry for that, I never noticed that and I dont any thing about PERL too.
  #5 (permalink)  
Old 07-31-2006
jim mcnamara jim mcnamara is online now Forum Staff  
...@...
  
 

Join Date: Feb 2004
Location: NM
Posts: 5,773
$logname doe not have a value. It appears to be a filename with an embedded date/time stamp.

UNIX time (internal) is a number of seconds since an arbitrary starting time.... 1900 is the 'earliest' year, so 2006 would be year 106 which is 2006 - 1900.

Months start counting from zero ie., Jan = zero , Feb = 1....
  #6 (permalink)  
Old 07-31-2006
12yearold 12yearold is offline
Registered User
  
 

Join Date: Jul 2006
Posts: 22
Thanks jim... i believe the 1900 is the epoch year right?.. okay...
then something is wrong...
it seems that i earlier suspected that it could be the assignment of values, but reborg confirms that its correct... hmmmm...
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 02:46 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0