#!/usr/bin/ksh echo "Checking date command availability and date arithmetic support..." # Check for date commands echo "Available date commands:" if command -v date >/dev/null 2>&1; then echo " date: $(which date)" DATE_CMD="date" else echo " date: NOT FOUND" fi if command -v gdate >/dev/null 2>&1; then echo " gdate: $(which gdate)" if [ -z "$DATE_CMD" ]; then DATE_CMD="gdate" fi else echo " gdate: NOT FOUND in PATH" # Check common HP-UX locations for gdate echo " Checking common HP-UX locations for gdate..." for gdate_path in /usr/local/bin/gdate /opt/gnu/bin/gdate /usr/contrib/bin/gdate /opt/coreutils/bin/gdate; do if [ -x "$gdate_path" ]; then echo " gdate: FOUND at $gdate_path" if [ -z "$DATE_CMD" ]; then DATE_CMD="$gdate_path" fi break fi done if [ -z "$DATE_CMD" ] || [ "$DATE_CMD" = "date" ]; then echo " gdate: NOT FOUND in common locations" fi fi if command -v perl >/dev/null 2>&1; then echo " perl: $(which perl)" PERL_AVAILABLE=1 else echo " perl: NOT FOUND" PERL_AVAILABLE=0 fi if [ -z "$DATE_CMD" ]; then echo "ERROR: No date command found!" exit 1 fi echo "" echo "Testing date arithmetic with: $DATE_CMD" # Test basic date echo "Basic date output:" $DATE_CMD +"%Y-%m-%d %H:%M:%S" # Test date arithmetic like used in rman_db.ksh echo "" echo "Testing date arithmetic: '$DATE_CMD +%m-%d-%Y\ %H:%M:%S -d \"-1 hour\"'" if $DATE_CMD -d "-1 hour" >/dev/null 2>&1; then RESULT=$($DATE_CMD +%m-%d-%Y\ %H:%M:%S -d '-1 hour') echo "SUCCESS: Date arithmetic works" echo "Result: $RESULT" else echo "ERROR: Date arithmetic (-d option) not supported" echo "This system may need GNU date (gdate) installed" fi # Test perl-based date arithmetic as fallback if [ $PERL_AVAILABLE -eq 1 ]; then echo "" echo "Testing perl-based date arithmetic fallback:" echo "Command: perl -e 'use POSIX qw(strftime); \$time = time() - 3600; print strftime(\"%m-%d-%Y %H:%M:%S\", localtime(\$time))'" PERL_RESULT=$(perl -e 'use POSIX qw(strftime); $time = time() - 3600; print strftime("%m-%d-%Y %H:%M:%S", localtime($time))') echo "SUCCESS: Perl date arithmetic works" echo "Result: $PERL_RESULT" else echo "" echo "WARNING: Perl not available - no fallback for date arithmetic" fi echo "" echo "Test complete."