LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 12-07-2006, 11:38 PM   #1
newbie_adm
Member
 
Registered: Jun 2006
Posts: 40

Rep: Reputation: 15
date errors


Hi, Just wanted to ask why is my script is not runnng correctly, but it used to work before. I have used the script for almost 2 months now. Just this day that it recieved an error. My script will get the yesterdays date and cdrfiles.

cdr_cal23 --> script name. This will the next day.And it wet get yesterdays data.

TIME parameters
YEAR1=`date '+%Y'`
DAY1=`date '+%d'`
(( DAY1 = DAY1-1 ))
if (( DAY1 < 10))
then DAY1="0"$DAY1
fi

I having errors on (( DAY1 = DAY1-1)) and on the if statement.

The errors are : "bash: ((: 08: value too great for base (error token is "08")"

What would I do with this, it used to work before without problems.

Please help.

Thanks
 
Old 12-08-2006, 12:00 AM   #2
matthewg42
Senior Member
 
Registered: Oct 2003
Location: UK
Distribution: Kubuntu 12.10 (using awesome wm though)
Posts: 3,530

Rep: Reputation: 65
You're close. Integer arithmatic can be done like this:
Code:
day=6
result=$(( $day - 1 ))
 
Old 12-08-2006, 12:08 AM   #3
newbie_adm
Member
 
Registered: Jun 2006
Posts: 40

Original Poster
Rep: Reputation: 15
I tried doing that thing. but resulted with the same errors. Please help. I tried running it on a HP-ux platform and it worked properly. I just wondering why it did not run successfully today. Please help.

Thanks
 
Old 12-08-2006, 12:12 AM   #4
matthewg42
Senior Member
 
Registered: Oct 2003
Location: UK
Distribution: Kubuntu 12.10 (using awesome wm though)
Posts: 3,530

Rep: Reputation: 65
Looks like your script is written for C style shells. linux uses bash (a borne style shell) by default, which uses different syntax.

You could install tcsh, and then have the first lilne of your script as:
Code:
#!/bin/tcsh
However, consider not using c shells - they're horrible to code in. Learn the borne style shell syntax - you'll never look back.
 
Old 12-08-2006, 02:37 AM   #5
AnanthaP
Member
 
Registered: Jul 2004
Location: Chennai, India
Posts: 952

Rep: Reputation: 217Reputation: 217Reputation: 217
I think "expr" will help.

For example: (have to check it out)
DAY1=`expr $DAY1 - "1"`

if [ DAY1 -lt `expr "10"` ]
then
DAY1=`echo 0$DAY1
fi
 
  


Reply



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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
thunderbird puts time instead of date under 'date' header wabbalee Linux - Software 4 11-26-2006 04:58 AM
current date - yesterday's date newbie_adm Linux - Newbie 4 09-04-2006 03:56 PM
Errors, Errors, and more Errors (KDE 3.4.x GUI Errors) Dralnu Linux - Software 2 05-13-2006 08:30 AM
Start Date + Time Duration = End Date/Time calculator? ToBe Linux - General 3 09-26-2005 10:17 AM
lastlog date does not match system date? jcmj Linux - Networking 6 10-22-2002 12:09 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 02:57 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration