Solved

Page follow through via date

Posted on 2001-07-16
9
153 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
Comment Utility
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
Comment Utility
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
Comment Utility
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
 

Author Comment

by:system
Comment Utility
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
Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

 
LVL 3

Accepted Solution

by:
interiot earned 200 total points
Comment Utility
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
Comment Utility
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
Comment Utility
Interiot: The server is Apache/1.3.17
0
 
LVL 1

Expert Comment

by:Moondancer
Comment Utility
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
Comment Utility
Comment from expert accepted as answer.

Thank you
Computer101
E-E Moderator
0

Featured Post

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

Introduction This tutorial will give you a fast look what you can do with WhizBase. I expect you already know how to work with HTML at least, and that you understand the basics of the internet and how the internet works. WhizBase is a server-s…
In this tutorial I will show you how to provide a dynamic RTF document on your website generated with data from your database. For this tutorial you will need Microsoft Word or WordPad, WhizBase and Microsoft Access. In this tutorial I will show …
Learn the basics of lists in Python. Lists, as their name suggests, are a means for ordering and storing values. : Lists are declared using brackets; for example: t = [1, 2, 3]: Lists may contain a mix of data types; for example: t = ['string', 1, T…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

743 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now