GaijinPunch has asked for the wisdom of the Perl Monks concerning the following question:

Hey monks: Here's the issue. I cleaned up my site that was in mass disarray. I'm using HTML::Template for the general layout, but there's a column in the page that needs to be dynamic. It queries my MySQL database, gets the latest info and prints it out. So, for that, I'm using ssi->exec(). I also have made this part of the page the part that keeps track of the hits.

The logic of the hit counter is that if the IP hasn't been logged that day, it logs it. The problem now, is that since that part of the script is run by ssi->exec(), $ENV{REMOTE_ADDR} will always return the address of the remote server. I tried something like this:
print $ssi->exec(cgi => 'http://myscript.cgi $ip_address');
But that didn't fly. Any suggestions besides putting the code on each of the 12 other scripts that make up the site?

Replies are listed 'Best First'.
Re: Passing an argument to an execute()ed script
by reneeb (Chaplain) on Aug 31, 2004 at 10:22 UTC
    I don't know the ssi-module, but try this:

    $ssi->exec(cgi => "http://myscript.cgi?ip=$ip_address");

    Then the ip_address is the parameter for 'ip'...
    With single quotes your variable isn't interpolated.
Re: Passing an argument to an execute()ed script
by perlfan (Parson) on Aug 31, 2004 at 11:04 UTC
    generally, "GET" requests, i.e. where name/values pairs are passed via the URL, take on the form:

    http://subdomain.domain.tld:<port#>/myscript.cgi?arg1=val1&arg2=val2

    You can skip the ":<port#>" part if you are using default httpd port 80. Also, characters like a space have to be written as '%20' like%20this%20here.
      I feel like such an idiot... I didn't even think about the URL.... (lowers head in shame).