# We need the $SYBASE and $LD_LIBRARY_PATH environment variables to be able # to use the Sybase::Simple library (because it links to libsybct.so in # $SYBASE/$SYBASE_OCS/lib), but if we are invoked through cron, then # ~/.profile doesn't get sourced and we are stuck with a nearly empty %ENV # hash. So if we detect $SYBASE is not in %ENV, reexec through a shell that # first sources in the necessary environment variables. unless (exists $ENV{SYBASE}) { # $^X is the path to the current perl interpreter # $0 is the script itself exec '/bin/sh', '-c', ". /db/sybsdk/SYBASE.sh ; exec $^X $0 @ARGV"; } # even with the above, we need to wrap the import of the Sybase Perl # module in a runtime block as to avoid initialization by the Perl compiler # prior to runtime (which checks for the necessary $SYBASE env variables). # See 'perldoc perlfaq8' as to the difference between 'use' and 'require'. # Basically: 'use' is ran at compile time, 'require' at runtime. require Sybase::Simple;