PERL Time problem

Hi All,

I have a website where the time is displayed, and it works just fine.  We have a server in our office, where we do our updates via a web interface.  When we are happy with what every thing looks like, we click a button on the interface, it runs a perl script, and ftp's files over to the server at our isp/web host, to our main website.  This all works fine.  The server in our office is getting very old, so I moved all of the files from it to a newer server, corrected the addressing inthe perl scripts, installed everything (i Think!) that is necessary, etc.  When I try to do the same process on the newer server, it ftp's all of the files it should, however that date on our website will revert back to January 1, 1970.  I'm familiar with how PERL figures out date and time, counting non leap seconds from 1970 etc.  My question is why is this all of the sudden changing the dates?  All we are doing is ftping (using Net::ftp) text files.  Has anyone ever encountered this problem?

Thanks

Brian
wxman1Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

manav_mathurCommented:
Brian,
One thing that you have not mentioned is how are you displaying time on your website.
Are you using CGI scripting or some other method......

Manav
0
wxman1Author Commented:
Manav,

It is perl scripting using CGI.

Brian
0
manav_mathurCommented:
okay!!

And you are using localtime to get the updated time.
Two of the stupidest suggestions that I can come with are

1) Have you by mistake tweaked with the actual code while moving servers.
2) Does the server have the time set??

Can you tell me what version of PERL you are using??

Manav
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Cloud Class® Course: CompTIA Healthcare IT Tech

This course will help prep you to earn the CompTIA Healthcare IT Technician certification showing that you have the knowledge and skills needed to succeed in installing, managing, and troubleshooting IT systems in medical and clinical settings.

wxman1Author Commented:
Manav,

1)  No I haven't touched the code, except for changing the addressing as the directory structure on the new server is slightly different.

2)  The older server is set for the current time.  The new server is set at GMT time, as most of our work is done in GMT.  The webserver, where are actual website resides, I am not sure.

There is a difference between the versions of PERL, the older server is running 5.22, and the newer one is running 5.8 (Active States version).  I'm not sure about the webserver hosted at our isp.

Brian
0
manav_mathurCommented:
If possible, can I see the PERL script which you run to ftp the files.

One thing that seems is that there's a version conflict somewhere. Your webserver has no role to play in this error, because Im assuming that the PERL script used to FTP files also inserts the last updated date somewhere in the webpage. SO I guess having a look at it might solve the problem

one more thing, you can go thru the docs for localtime. Even I have Active state 5.6.

Manav
0
wxman1Author Commented:
Script is below:
###################
use CGI;
use Net::FTP;

require "c:/Inetpub/wwwroot/oldweb/www.weather.bm/cgi-bin/weather-util.pl";

$LOCATION="REMOTE";

chdir("$HOMEDIR/cgi-bin");

$in=new CGI;

# Make sure that data was posted (ie. CGI was started properly for an update).
if ($in->param("u") eq "1") {

   # The following actions always take place, whether CGI run on main server or remotely (at BWS)...
   print "Location: /update/complete.html\n\n";

   if (opendir(DIR,".")) {
      @files=readdir(DIR);
      closedir(DIR);

      # Mark "old" files for deletion - try to be a bit cleaner. :^)
      foreach $file(@files) {
         if ($file=~/^cur-[^\.]+\.txt$/) { $Delete{$file}=1; }
         print $file."\n";
      }

      # Copy new files to new names.
      foreach $file(@files) {
         if ($file=~/^tmp-([^\.]+)\.txt$/) {
            $name=$1;
            system("copy $file cur-$name.txt");
            $Delete{"cur-$name.txt"}=0;
            print "Copied $file to cur-$name.txt\n";

            # Make a record of files to keep (and where to put on main server), if FTPing them later is needed.
            $Keep{"cur-$name.txt"}="";
         }
      }

      # Delete unneeded files.
      foreach $file(keys %Delete) {
         if ($Delete{$file}) {
            unlink($file);
            print "Deleted $file.\n";
         }
      }
}

if ($LOCATION eq "REMOTE") {

      # Remote machine must also FTP all the updated, current TXT files it has to the server.
      # (all files that have a cur-xxx.txt and tmp-xxx.txt versions)
      SendFTP("i.p.address","username","password",%Keep);
   }

else {
   print "Content-type: text/html\n\n";
   print <<ENDTEXT;
<HTML>
<HEAD>
<TITLE>Weather Page Update</TITLE>
</HEAD>
<BODY bgcolor=#e3fff2 text=#000000 link=#0a50a1 vlink=#0a50a1 background="/back/coral-thin.gif">
<FONT face="Arial, Geneva, Helvetica, San-serif">
<TABLE border=0>
<TR><TD valign=top width=220><IMG src="/blank.gif" width=220 height=1></TD>
    <TD>
    <B>Update Weather Page.</B><P>

    The weather pages have <B>not</B> been updated with the files from the preview site - please do not bookmark this page.
   
    <P><A href="/">Go to main weather page</A><BR>
    <A href="/update/">Go to preview area</A></P>
    </TD>
</TR>
</TABLE>
</FONT>
</BODY>
</HTML>
ENDTEXT
}
exit(0);

sub SendFTP {
# Performs FTP Upload functions.

   my($host,$user,$pass,%files)=@_;
   my($dir,$file,$ext,$mode,$ftp);

   my(%ASCII)=("TXT"=>1,"HTML"=>1,"SHTML"=>1,"HTM"=>1,"PL"=>1,"PM"=>1);

   $mode="UNKNOWN";
   if ($ftp = Net::FTP->new($host)) {
      if ($ftp->login($user,$pass)) {
         
         foreach $file(sort keys %files) {

            # Change to appropriate directory.
            $dir=$files{$file};
            if ($dir ne "") { $ftp->cwd($dir); }

            # Change mode if necessary.
            if ($file=~/\.(.+)$/) { $ext=uc($1); } else { $ext="none"; }
            if (($ASCII{$ext})&&($mode ne "ASCII")) { $ftp->ascii(); $mode="ASCII"; }
            elsif ((!($ASCII{$ext}))&&($mode ne "BINARY")) { $ftp->binary(); $mode="BINARY"; }

            # Send file.
            $ftp->put($file);
         }
      }
      $ftp->quit;
      return 1;
   }
   return 0;
}
0
wxman1Author Commented:
sorry, forgot a line of code

After :
if ($LOCATION eq "REMOTE") {

      # Remote machine must also FTP all the updated, current TXT files it has to the server.
      # (all files that have a cur-xxx.txt and tmp-xxx.txt versions)
      SendFTP("i.p.address","username","password",%Keep);
   }


should be:

 # Machines should also FTP graphics and HTML for tracking maps if needed.
   %Keep=();
   foreach $file(@files) {
      if (($file=~/^map-\d+-\d+.png$/)||($file=~/^map-\d+-bg.png$/)||($file=~/^map-\d+-plot.html$/)) { $Keep{$file}=""; }
   }
0
wxman1Author Commented:
Manav,

Well I figured out what my problem was, the Net::ftp was not using passive mode!  I don't know why that was causing the problems, but I have corrected it and it now works.  Since you were kind enough to try and help, the points are yours.

Cheers,

Brian
0
manav_mathurCommented:
Great!!

Sorry couldnt help you more last time. It was 10 in the night and I had to leave my office.

Manav
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Perl

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.