SSI newbie: '#exec' can't take arguments?

SSI newbie: '#exec' can't take arguments?

Post by Isaac Wilco » Thu, 25 Mar 1999 04:00:00



Trying out SSI for the first time on my Apache 1.3.0 server, I decided
to write a small Perl script to output the current time on the server.
No problem - the SSI:

<!--exec cmd="clock.pl" -->

inserted the correct time into my page.
Then I added the ability to take an 'adjustment' argument, a figure in
hours to adjust the clock by, e.g.

Quote:> clock.pl +2

The script runs fine when I telnet to the server and execute that line,
but when I include the SSI:

<!--exec cmd="clock.pl +2" -->

into my web page I get no output, as if the SSI were simply replaced
with
nothing. Similarly,

<!--exec cmd="/bin/ls" -->

works, but

<!--exec cmd="/bin/ls -la" -->

does not.

The Apache documentation says:

Quote:>      ...
> exec
>      The exec command executes a given shell command or CGI script.
>      The valid attributes are:
>        cmd
>          The server will execute the given string using /bin/sh.
>          The standard include variables are available to the command.
>        cgi
>      ...

What am I missing ?

Thank you,

Isaac Wilcox

:)

 
 
 

SSI newbie: '#exec' can't take arguments?

Post by Jerry Stratt » Sun, 28 Mar 1999 04:00:00




>Trying out SSI for the first time on my Apache 1.3.0 server, I decided
>to write a small Perl script to output the current time on the server.
>No problem - the SSI:

><!--exec cmd="clock.pl" -->

>inserted the correct time into my page.
>Then I added the ability to take an 'adjustment' argument, a figure in
>hours to adjust the clock by, e.g.

>> clock.pl +2

>The script runs fine when I telnet to the server and execute that line,
>but when I include the SSI:

><!--exec cmd="clock.pl +2" -->

>into my web page I get no output, as if the SSI were simply replaced
>with
>nothing. Similarly,

><!--exec cmd="/bin/ls" -->

>works, but

><!--exec cmd="/bin/ls -la" -->

>does not.
>What am I missing ?

Two ways around this offhand.

1. Write a wrapper script/cgi that calls the commands.

2. Use either "include virtual" or "set var" to set the options you want.
For example:

<!--#include virtual="myls.cgi?options=la" -->

or

<!--#set var="options" value="la" -->
<!--#exec cmd="/somewhere/myls" -->

In the first case, look in the QUERY_STRING to get the options; in the
second case, look in the environment variables (in Perl, $ENV{'options'}).
(You can also use the 'set var' ssi along with 'include virtual', if you
prefer.)

The latter 'myls' script could be as simple as:

#!/usr/local/bin/perl
$theOptions = $ENV{'options'};
$theCommand = "/bin/ls -$theOptions";
$theResults = `$theCommand`;
print $theResults;

although depending on what you're doing you might want to be a bit more careful.

Jerry
http://www.hoboes.com/jerry/

 
 
 

1. Taking arguments from pipe 'plus' one more argument

Hi there,

Suppose we have this

code1 ---> which generate file1.txt
and
code2 ----> which take "file1.txt" PLUS one more argument e.g. "file2.txt"

Is there any way we can do it in one line with Bash?

e.g. perl code1 | code2 (don't know what to add) file2.txt

Hope to hear from you again.
Thanks so much for your time.

Regards
Edward WIJAYA

--
Using M2, Opera's revolutionary e-mail client: http://www.opera.com/m2/

2. linux ppp connect to 3com ISP server problem...

3. Need 'exec.h' file or 'struct exec' definition

4. Time Zone Change

5. init: can't exec getty 'perl' for port /dev/cuaa0

6. Many failures in nmbd and upd

7. 'find' and -exec'd pipes

8. RPC Timed out

9. init: can't exec getty 'none' ...

10. Apache's SSI doesn't work for virtural hosts' directories.

11. init: can't exec getty '/usr/libexec/getty' for port /dev/ttyv0:

12. 'make' gives can't exec cpp

13. There goes the old 'linux isn't vulnerable' argument..