LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Enterprise (https://www.linuxquestions.org/questions/linux-enterprise-47/)
-   -   RHEL4u2 perl localtime() call issues (perl & glibc) (https://www.linuxquestions.org/questions/linux-enterprise-47/rhel4u2-perl-localtime-call-issues-perl-and-glibc-521155/)

Brad.Scalio@noaa.gov 01-20-2007 09:18 AM

RHEL4u2 perl localtime() call issues (perl & glibc)
 
Greetings
(long time lurker, 1st time poster)


Recently installed RHEL4u2 (2.6.9-37) onto all servers and nodes at a remote site -- the problem is when called localtime() within Time::Local for perl 5.8.5

The RHEL4u2 came with some perl updates, now inside a lot of scripts we had calls to localtime() from within the Time::Local module, then inside the same script we define TZ environment variable and call localtime() again, but it doesn't recognize the new TZ...this worked fine in RHEL3 and works fine on my machine (Fedora Core 6)... so it looks like something in the RHEL4u2 perl-*5.8.5*rpm caused this.

My question now is, does anyone know if RHEL4u2 for whatever reason has maybe localtime() linked to glibc's localtime_r() or vice versa...the only possible answer I can come up with is that tzset[] is being called before each localtime() call inside the scripts thus no matter what TZ is set to inside the script, the call before the localtime() call supersedes it....

I can't find anything on google, couldn't find anything in the forum, tried our RedHat support folks, but their answer is always to install the new rpm or update, but on a nation-wide system which requires a national baseline to interconnect we just can't do that on a whim, it takes an act of G-d to get the baseline changed.

Any help appreciate, and apologies if this is the wrong thread, or already answered 10^100 times

Brad.Scalio@noaa.gov 01-21-2007 09:24 AM

just in case anyone references this, the solution:

perl5-8-5 changed the calls to tzset glibc to be from perl localtime() to localtime_r() :: so localtime() no longer calls tzset but rather, localtime_r() calls tzset in perl no for RHEL distr --- you can call tzset before the localtime calls or just edit the scripts you use to have localtime_r() called simple enough


set tz=CST+06CDT
tzset();
my $now = localtime;
print "Calling 'localtime' function without an TZ:\n";
print "\tThe time/date is: $now.\n";

or

call localtime_r() instead of localtime()

gotta admit I still use and love VI so I just did:

:g/localtime/s//localtime_r/gc

thanks again guys/gals - have a good one

unSpawn 01-21-2007 12:32 PM

Thanks for posting your solution, it's appreciated.

Capt_Caveman 01-23-2007 09:27 PM

In the future, please only post a single thread for your topic rather than posting in multiple forums. Thanks. Closing thread. Please direct replies to:

http://www.linuxquestions.org/questi...d.php?t=521188


All times are GMT -5. The time now is 10:48 PM.