Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

strange!!!! 2

Status
Not open for further replies.

mrn

MIS
Apr 27, 2001
3,993
GB
Can anyone replicate this for me on AIX 5.2

function convert_time_to_seconds {
echo $1|tr ':' ' '|read hrs min sec
echo $((($hrs*60*60)+($min*60)+$sec))
}

convert_time_to_seconds 14:00:07

works fine

convert_time_to_seconds 14:00:09

convert_time_to_seconds[2]: 09: 0403-009 The specified number is not valid for this command.

This script worked fine on 4.3.3, anyone got any idea?


--
| Mike Nixon
| Unix Admin
|
----------------------------
 
been through rest of the numbers 0-59 and only get this error for 08 & 09

if I do 14:00:8 or 14:00:9 it works

but not 14:00:08 or 09


--
| Mike Nixon
| Unix Admin
|
----------------------------
 
Right 08 09 are octal numbers, it looks like 5.2 ksh handles these in a different way from 4.3.3. If I put #!/bin/ksh93 it works.

or put

typeset -LZ hrs
typeset -LZ min
typeset -LZ sec

at the start of the script

--
| Mike Nixon
| Unix Admin
|
----------------------------
 
Hi,

It works too if you don't use dollar signs for vars inside parentheses :

echo $(((hrs*60*60)+(min*60)+sec))

Ali
 
ogniemi - no I hadn't thanks

aau - Much easier than my solution - thanks

--
| Mike Nixon
| Unix Admin
|
----------------------------
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top