Solved

Page follow through via date

Posted on 2001-07-16
9
160 Views
Last Modified: 2013-12-25
What is the cleanest way to display a static HTML document in CGI, based on the current date?

i.e. User accesses main.cgi
and the script outputs to monday.html, tuesday.html etc... based on the current date..
0
Comment
Question by:system
9 Comments
 
LVL 3

Expert Comment

by:interiot
ID: 6287787
use CGI qw(redirect);
use POSIX qw(strftime);

$day = lc(strftime("%A", localtime));
print redirect(-uri=>"http://www.yourserver.com/$day.html");


The redirect URL can be a relative path as well, if you'd like.
0
 

Author Comment

by:system
ID: 6302649
I got an internal error (500)
I am running a Linux distrib. with Apache.

are there compatible libraries to the ones above?
0
 
LVL 3

Expert Comment

by:interiot
ID: 6302786
Can you check apache's logs to see what the error was?

Here's an alternate (not so clean) version:

     my @days=qw( sunday monday tuesday wednesday thursday friday saturday);
     my $day=$days[ (localtime)[6] ];
     print "Location: http://yourserver.com/$day.html\n";
0
DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

 

Author Comment

by:system
ID: 6304288
hmm...

That last one, screwed up as well....
error 500 misconfiguration....

I am not sure what is going on, It's not the server, and I am setting the correct chmod permissions because other scripts are working fine.

Any ideas, on formatting or adding includes??
0
 
LVL 3

Accepted Solution

by:
interiot earned 200 total points
ID: 6304307
The second one doesn't need any includes, all its functions are standard, as long as you're not using a really old version of perl.

Are you including the #!/usr/bin/perl or similar at the top?  Is it the same path used in your other scripts?

What web server are you running?  Do you know if you're able to look at the server's error logs?  (they'll show you some problems with your script, not just with the server setup)

Try adding the following lines to the begining of your script, and if the error is only in the perl script, it'll display the errors to your browser instead of to the server log:
       ## death handler, presumes no output yet
       $SIG{``__DIE__''} = $SIG{``__WARN__''} = sub {
            my $error = shift;
            chomp $error;
            $error =~ s/[<&>]/``&#''.ord($&).``;''/ge;
            print ``Content-type: text/html\n\n[$error]\n'';
            exit 0;
       };
           
0
 

Author Comment

by:system
ID: 6385718
My other perl scripts (working) have: #!/usr/bin/perl
as the first line....

same error even with Interiot's debugging death handler:

Internal Server Error
The server encountered an internal error or misconfiguration and was unable to complete your request.
Please contact the server administrator, webmaster@brainfuel.ca and inform them of the time the error occurred, and anything you might have done that may have caused the error.

More information about this error may be available in the server error log.


Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request.

0
 

Author Comment

by:system
ID: 6385732
Interiot: The server is Apache/1.3.17
0
 
LVL 1

Expert Comment

by:Moondancer
ID: 6699420
Please update/finalize.  You may also benefit by posting this in the Perl topic area.

Moondancer
Community Support Moderator @ Experts Exchange
0
 
LVL 1

Expert Comment

by:Computer101
ID: 6903869
Comment from expert accepted as answer.

Thank you
Computer101
E-E Moderator
0

Featured Post

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Is it true to say that Python is successor of Perl? 7 175
Catch Cancellation error from objShell.Run 10 80
AWS CLI issues with Tags 3 77
Example unit tests with AngularJS 3 45
It is a general practice to get rid of old user profiles on a computer  in a LAN environment. As I have been working with a company in a LAN environment where users move from one place to some other place at times. This will make many user profil…
Active Directory replication delay is the cause to many problems.  Here is a super easy script to force Active Directory replication to all sites with by using an elevated PowerShell command prompt, and a tool to verify your changes.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…

778 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question