Gossamer Forum
Home : General : Perl Programming :

SSI command? if file > 3 hrs old

Quote Reply
SSI command? if file > 3 hrs old
Ok what is the SSI command to run test.cgi if test.html file is over 3 hours old?
<!--#exec cgi="/cgi-bin/test/test.cgi" (This works fine currently, but I only want to run if the file test.html is more than 3 hours old)
I know this:
#flastmod virtual (Gives me the date modified)
#DATE_LOCAL (Gives me Local time)

What do I need to do to execute if difference is < 3 hours?

Quote Reply
Re: [Hank] SSI command? if file > 3 hrs old In reply to
Something like.....

Code:
if (int(((-M "test.html" * 12) / 4)) > 3) {
_do_something();
}

...may work.

Last edited by:

RedRum: Oct 22, 2001, 9:14 AM
Quote Reply
Re: [RedRum] SSI command? if file > 3 hrs old In reply to
Using only SSI commands? I don't think whoever asked the question was using any perl/php or anything else to drive his pages.

I don't think there is a way to do this using just SSI?

Cheers

- wil
Quote Reply
Re: [Wil] SSI command? if file > 3 hrs old In reply to
That code goes in the test.cgi script Crazy
Quote Reply
Re: [RedRum] SSI command? if file > 3 hrs old In reply to
Bingo!

;-)

- wil
Quote Reply
Re: [Wil] SSI command? if file > 3 hrs old In reply to
Check this page of SSI...
I think there is a way of doing it, but not sure about the long commandBlush
http://www.carleton.ca/~dmcfet/html/ssi3.html
Quote Reply
Re: [Hank] SSI command? if file > 3 hrs old In reply to
Hey Hank you'd need to change that to:

Code:
my $days = -M "test.html";

Code:
if (int((($days * 12) / 4)) > 3) {
code contained in test.cgi goes here;
}
else {
do nothing;
}

Last edited by:

RedRum: Oct 22, 2001, 9:55 AM
Quote Reply
Re: [Hank] SSI command? if file > 3 hrs old In reply to
Hank,

I think my method is best (not meaning to be arrogant) as all code is contained in one script then.
Quote Reply
Re: [RedRum] SSI command? if file > 3 hrs old In reply to
Thx... I am trying it right now... server keeps giving me errorsFrown
This is the code I did:
Code:
#!/usr/bin/perl
my $days = -M "test.html";

if (int((($days * 12) / 4)) > 3) {

print "Hello, World...\n";
else {

print "Hello, World checking this...\n";

do nothing;}

I know I am missing something here... because the errors... Need to get mor CoffeeSmile
If you see it before me post it here.
Thx
Quote Reply
Re: [Hank] SSI command? if file > 3 hrs old In reply to
You need to print a header :)

Try...

Code:
#!/usr/bin/perl

print "Content-type: text/html\n\n";

my $days = -M "test.html";

if (int((($days * 12) / 4)) > 3) {
print "Hello, World...";
else {
print "Hello, World checking this...";
}

....make sure test.html exists in the same directory as test.cgi - if not you'll need to add the full path like:

my $days = -M "/FULL/PATH/TO/test.html";

Last edited by:

RedRum: Oct 22, 2001, 10:39 AM
Quote Reply
Re: [Hank] SSI command? if file > 3 hrs old In reply to
I don't even know why I added / 4 - it _should_ be:

Code:
#!/usr/bin/perl

print "Content-type: text/html\n\n";

my $days = -M "test.html";

if (int($days * 24) > 3) {
print "Hello, World...";
} else {
print "Hello, World checking this...";
}

Last edited by:

RedRum: Oct 22, 2001, 11:21 AM
Quote Reply
Re: [RedRum] SSI command? if file > 3 hrs old In reply to
Cool Thx...Cool

Got it working... My perl is not as good as you guys, but I had to add "}" for above code to get it working..

Thx again, you saved my day.
Hank
Quote Reply
Re: [Hank] SSI command? if file > 3 hrs old In reply to
Quote:
but I had to add "}" for above code to get it working..

Oops missed that ...before else { Blush...I edited the code above incase anyone else decides to try it.

Last edited by:

RedRum: Oct 22, 2001, 11:22 AM
Quote Reply
Re: [RedRum] SSI command? if file > 3 hrs old In reply to
...there is a way to do it... using extended SSI. I'm not familiar with using it myself but I've seen it somewhere like at BigNoseBird or something.

--Philip
Links 2.0 moderator