I have a script called S1.sh This script calulates the current seconds since epoch time and then gives me the current time.
S1.sh
#!/bin/ksh
set -x
TZ=`date +%Z`+0 ;a=`date +%Y-%m-%d`
echo $a
current_time=`date +%s`
echo "$current_time"
perl -le 'print scalar localtime('$current_time');' | awk '{print $4}' | cut -c 1-5
The problem here is the below command in the script giving the wrong time but when i type the same command in the command prompt it gives the correct result
In the script
perl -le 'print scalar localtime('$current_time');' | awk '{print $4}' | cut -c 1-5
output:
8:49
In the command prompt. let say the seconds are i.e. $current_time = 1241513359
perl -le 'print scalar localtime(1241513359);' | awk '{print $4}' | cut -c 1-5
output:
3:49