The UNIX and Linux Forums  

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




View Single Post in the UNIX and Linux Forums - Click on the Thread or Permalink to View Entire Thread -->
  #1 (permalink)  
Old 03-17-2009
SGD SGD is offline
Registered User
  
 

Join Date: Mar 2009
Posts: 1
Reading Hours and Minutes from file and comparing with current

Hi,

Time till when the application should run is indicated in a file. First line is hour and second line is minute.
file:
10
55
Means my application should run till 10:55.

Now in a shell script, i am trying to make that logic but with no luck.

min=`tail -n 1 /file_with_time`
hour=`head -n 1 /file_with_time`

chour=`date +%H`
cmin=`date +%M`

if [ $chour < $hour ] <== Shell script throws error here when value is two digits ie if first line the file is > 9.
then
run_my_app
fi

if [ $chour = $hour ]
then if [ $cmin < $min ]
then
run_my_app
fi
fi

Kindly suggest.
SDG