Listing 2 GetEpochTime test script
# GetEpochTime test script
echo $(GetEpochTime)
# Call Perl to print Epoch time.
perl -e 'print time,"\n";'
# Call GUN date to print Epoch time.
date +"%s"
# Call cc or gcc installed you can run the
# following code to get "C" Epoch time.
CreateTmpFile ()
{
cat > epochCcode.c <<'EOF'
#include <stdio.h>
main()
{
printf("%u\n", time(NULL));
}
EOF
trap 'rm -i ./epochCcode*; exit 1' 1 2 3 15
}
if [[ ! -f epochCcode.c ]] && [[ ! -f epochCcode.out ]]
then
if type cc >/dev/null 2>/dev/null
then
CreateTmpFile
wait
cc -o epochCcode.out epochCcode.c
elif type gcc >/dev/null 2>/dev/null
then
CreateTmpFile
wait
gcc -o epochCcode.out epochCcode.c
else
echo "Can't find cc or gcc. Exiting...."
exit
fi
chmod 755 epochCcode.out
./epochCcode.out
rm -f epochCcode.out epochCcode.c
else
echo "Exiting: Either epochCcode.c or epochCcode.out already exists."
fi
|