http://qs1969.pair.com?node_id=127660

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

i was hoping to use Getopt::Long to pass some configuration options to a SSI using #exec cmd, however i had no such luck. what is the best method of passing into to an ssi script? i'd like to be able to let the end user select a date format by providing some info in their html. i had hoped that something like <!--#exec cmd="cgi-bin/date.cgi --style=5"--> or <!--#exec cgi="cgi-bin/date.cgi?style=5"--> might be the answer, but neither seems to let me do what i am shooting for.

humbly -c

Replies are listed 'Best First'.
Re: Passing variables to an SSI script
by perrin (Chancellor) on Nov 27, 2001 at 03:58 UTC
    exec is deprecated. You should use include virtual instead, which allows you to pass a query string. If you're not using Apache, you'd better consult the docs for your particular server.
Re: Passing variables to an SSI script
by merlyn (Sage) on Nov 27, 2001 at 05:32 UTC
Re: Passing variables to an SSI script
by tune (Curate) on Nov 27, 2001 at 03:57 UTC
    You can use the first method only
    <!--#exec cmd="cgi-bin/date.cgi --style=5"-->
    That should work. Perhaps if you show more of your code, someone will be able to help.

    Greetings,

    --
    tune

      Using <!--#exec cmd="cgi-bin/date.cgi --style=2"--> ends up being parsed, but with no output. My code snippet is:

      #!/usr/bin/perl -w use strict; use POSIX qw(strftime); use Getopt::Long; ## taint environmentals delete @ENV{qw(IFS CDPATH ENV BASH_ENV)}; $ENV{'PATH'} = "/usr/local/jail"; ## set up opts my $style = "1"; GetOptions ( 'style=s' => \$style, ); ## select style of date representation my $date; ## November 26, 2001 if ($style == "1") { $date = strftime("%B %e, %Y", localtime); ## 26 November 2001 } elsif ($style == "2") { $date = strftime("%e %B %Y", localtime); } print "Content-type: text/html\n\n"; print "$date\n";

      humbly -c

Re: Passing variables to an SSI script
by dws (Chancellor) on Nov 27, 2001 at 04:13 UTC
    i'd like to be able to let the end user select a date format by providing some info in their html. i had hoped that something like <!--#exec cmd="cgi-bin/date.cgi --style=5"-->

    You might be getting bit by a very obscure fact about HTML comments, which is that the end of the comment is delineated by double dashes. Everything between those and the closing angle bracket is ignored. In your case, that means that a fully standard-compliant SSI implementation might be discarding "style=5 --".

    Assuming your .cgi can accept shorter arguments, something like  <!--#exec cmd="cgi-bin/date.cgi -s=5> might work.