The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
.
google unix.com



UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !!

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
how do i put a time stamp in a file name jhamm Shell Programming and Scripting 5 01-29-2007 10:00 AM
Date/Time Stamp JimmyFlip UNIX for Dummies Questions & Answers 0 11-14-2006 11:49 PM
greping with time stamp arunkumar_mca Shell Programming and Scripting 1 07-28-2006 04:20 AM
capturing the time stamp pavan_test UNIX for Dummies Questions & Answers 4 07-18-2006 01:35 PM
Date Time Stamp jarich Shell Programming and Scripting 2 07-28-2005 09:28 PM

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 08-22-2007
Manvar Khan Manvar Khan is offline
Registered User
  
 

Join Date: Jul 2007
Posts: 6
Question checking time stamp

Hi,
I am having a script in which I am again calling a script, but before calling that script I need to perform a time check (say 1 - 2 am i.e. I would be able to call that script if time is between 1:00 am and 2:00 am) but this time stamp needs to be configurable.
can anybody suggest me how I can achive this..


Thanks in advance
Manvar
  #2 (permalink)  
Old 08-22-2007
namishtiwari namishtiwari is offline Forum Advisor  
Registered User
  
 

Join Date: Aug 2007
Location: Bangalore
Posts: 377
Thumbs up

Quote:
Originally Posted by Manvar Khan View Post
Hi,
I am having a script in which I am again calling a script, but before calling that script I need to perform a time check (say 1 - 2 am i.e. I would be able to call that script if time is between 1:00 am and 2:00 am) but this time stamp needs to be configurable.
can anybody suggest me how I can achive this..


Thanks in advance
Manvar

You can do something like this--

#!/bin/ksh
echo "To run a script in between a given time"
str1=`date | cut -d" " -f4`
str2=`echo $str1 | cut -d":" -f1`
if [[ $str2 -eq 13 ]] or if [[ $(date +%h) -eq 13 ]]
then
ksh test2
else
echo "Wrong"
fi


Thanks
Namish

Last edited by namishtiwari; 08-22-2007 at 04:19 AM..
  #3 (permalink)  
Old 08-22-2007
vino's Avatar
vino vino is offline Forum Staff  
Supporter (in vino veritas)
  
 

Join Date: Feb 2005
Location: Bangalore, India
Posts: 2,798
Without so many 'cut's
Code:
#! /bin/ksh

if [[ $(date +%H) -eq 01 ]] ; then
  echo "Judgement day has arrived"   # run the script
else
  echo "Judgement day has not arrived"
fi
  #4 (permalink)  
Old 08-22-2007
Manvar Khan Manvar Khan is offline
Registered User
  
 

Join Date: Jul 2007
Posts: 6
thanks Namish for your reply,
but this is not the solution I want, as per your solution

if [[ $str2 -eq 13 ]]

now in future if I want to change 13 to 15 then I have make changes in the code.
and I dont want to cahnge in the code.
I want my script capable of taking this time from some where outside this script.
I hope you got my problem.

Regards
Manvar
  #5 (permalink)  
Old 08-22-2007
vino's Avatar
vino vino is offline Forum Staff  
Supporter (in vino veritas)
  
 

Join Date: Feb 2005
Location: Bangalore, India
Posts: 2,798
Code:
#! /bin/ksh
#
#

case $# in
    2) start=$1; end=$2 ;;
    *) echo "Need a start and end time"; exit 1;;
esac

now=$(date +%H)
if [[ $now -ge $start && $now -lt $end ]] ;
then
    echo "Judgement Day has arrived."
else
    echo "Judgement Dat yet to arrive."
fi;
  #6 (permalink)  
Old 08-22-2007
Manvar Khan Manvar Khan is offline
Registered User
  
 

Join Date: Jul 2007
Posts: 6
thanks vino,
I am sorry I forgot to tell that we cannot use command line aurguments here (It is the requirement).

Regards
Manvar
  #7 (permalink)  
Old 08-22-2007
namishtiwari namishtiwari is offline Forum Advisor  
Registered User
  
 

Join Date: Aug 2007
Location: Bangalore
Posts: 377
Thumbs up

Manvar,
You can read the time like this

echo "Enter the start time stamp"
read stime

echo "Enter the end time"
read etime

and do your manipulations on these variables itself.
is that going to help you.

Thanks
Namish
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 01:01 AM.


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