Gossamer Forum
Home : General : Perl Programming :

Greetings Script

Quote Reply
Greetings Script
Hi, I downloaded and successfully installed (on a test page) Alex's Greetings script a little while back. I'm curious about the country codes. Is there any way to test how they will display through the script? I assume that section is based on the country code of your dial-up?

Also, Alex, there is a slight typo just below where the script prints out on your front page:

"Gossamer Threads offer a wide range"

Thanks,
Dan
Quote Reply
Re: Greetings Script In reply to
Hi Dan,

I've never used this script, although it is a nice touch! Anyway, as far as I can see, the script gets the remote_host (the server you're travelling through the internet with) and compares it to the domains.tab file. This is done in the subroutine get_country, which is called like this:

my $country = &get_country;

So if you want to see what it looks like for someone coming from, for example, France, you could define $country by changing that line to something like this:

my $country = "somedomain.fr";

Don't forget to change it back though! Smile

adam
Quote Reply
Re: Greetings Script In reply to
Hmm, sounded promising but still didn't seem to do anything. Frown There's no country or country code printout, just like if I don't modify that section. This can't be that complicated!

If nothing else, at least it's a nice little greeting/time of day script...

Dan
Quote Reply
Re: Greetings Script In reply to
Hi again Dan,

Well, sorry about that. I tried it myself there locally and you're right, it doesn't seem to work. I'll have a tinker at it tonight to see if I can figure it out.

Maybe you should take a holiday in some foreign country? For research purposes obviously... Smile

adam

[This message has been edited by dahamsta (edited May 19, 1999).]
Quote Reply
Re: Greetings Script In reply to
Adam,

Thanks for the reply. That partly accomplished what I was looking for, but not completely. Anything that I substitute in for &get_country (such as somedomain.fr) gets printed out directly by the script. I can't tell if that's a problem with the country code conversion, or if it's because &get_country has been replaced...?

If anyone's interested in taking a look to see what it shows for them, my test page with the Greeting script is at:

www.dankaplan.com/test2.shtml

It's about half-way down the page.

Thanks,
Dan
Quote Reply
Re: Greetings Script In reply to
I'm a silly, silly man, I forgot that the subroutine get_country does the checking aswell. Ok, I guess you could change &get_country to this to see it work:

Code:
sub get_country {
# --------------------------------------------------------------
my ($match, $code, $name);

$match = "somedomain.fr"; # Remove this line when you're done checking!

# if (exists $ENV{'REMOTE_HOST'} and ($ENV{'REMOTE_HOST'} =~ /\.(..)$/)) {
# $match = $1;

open (DOMAINS, "./domains.tab") or (print "SYSTEM ERR: CANT OPEN FILE" and exit);
while (<DOMAINS> ) {
chomp;
($code, $name) = split (/:/);
($code eq $match) and close DOMAINS and return $name;
}
close DOMAINS;
# }
return undef;
}

I've just commented out the lines that check for remote host, so you can change it back by removing the comments and the line:

$match = "somedomain.fr"; # Remove this line when you're done checking!

Hope that does it for you!

adam
Quote Reply
Re: Greetings Script In reply to
This is somewhat off the subject, but being a typesetter for a printing company, grammar is an integral part of my job. Regarding the first post of this thread by Dan, the sentence should read "Gossamer Threads OFFERS" because 'Gossamer Threads' is singular, not plural.

[This message has been edited by Lee (edited May 20, 1999).]
Quote Reply
Re: Greetings Script In reply to
Lee,

Not quite sure if you're agreeing with me or correcting me... At any rate, I was pointing out what the page currently says, not what it should say. I didn't even think of the potential confusion in Threads being considered plural. Smile But now we're definitely getting off topic!

Anyone know how to test the country codes? Wink
Quote Reply
Re: Greetings Script In reply to
Hi Dan, Thanks for the grammar fix!

As for the country code, Adam was close, but it wasn't working because domains tab looks for a two letter country code, not the whole domain. Try the original, but replace $match = $1 with $match = 'fr' to test for hosts with a .fr extension.

Hope this helps,

Alex

Quote Reply
Re: Greetings Script In reply to
Thanks for the suggestion, Alex, but still no luck. Frown I tried several different country codes, but I still got no resulting output (other than the greeting and the time). I assume someone must have this part of the script working?!

Dan
Quote Reply
Re: Greetings Script In reply to
Same here, can't get the lower part to work but the upper part did print.

Tried changing here and there, but still no luck. Hope someone who managed to install the greetings script without any problem help us here.