• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 290
  • Last Modified:

Execution of "embedded" args?

<td width="72"><!--#exec cgi="/home/j2/public_html/cgi-bin/cread.cgi?/cafe/Stories/humor/SAM-howto.shtml"--> </td>

doesnt work to good.. "error parsing argument" or so.

Whats the correct way to do this?
0
j2
Asked:
j2
  • 8
  • 6
  • 2
  • +2
1 Solution
 
fasterCommented:
This is SSI: server side include.  First, make sure that your server support SSI, second, check your server's document on how to config SSI (for example, you may have to specify a direcrtory for SSI, depending on what server you use)
0
 
ozoCommented:
<!--#exec cmd="QUERY_STRING='/cafe/Stories/humor/SAM-howto.shtml'; /home/j2/public_html/cgi-bin/cread.cgi"-->
0
 
j2Author Commented:
Thats definitely the wrong answer.
0
Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
j2Author Commented:
ozo: Ill test that as soon as i get to work! makes some sense :)

For now repost that comment as an answer, so the question gets locked.
0
 
j2Author Commented:
ozo: however, that also failed. still says "an error occured while processing this directive"




0
 
chrisboltCommented:
Try this:

<!--#include virtual="/home/j2/public_html/cgi-bin/cread.cgi?/cafe/Stories/humor/SAM-howto.shtml"-->
0
 
chrisboltCommented:
Try this:

<!--#include virtual="/cgi-bin/cread.cgi?/cafe/Stories/humor/SAM-howto.shtml"-->

You may have to fix the start to reflect the path to the CGI script from the web.
0
 
j2Author Commented:
No... still no go.. here is more background.

I have two short programs, one that counts pages hits "invisible" and another that reads the logfile and prits the hitcount.  if i call the read program with www.blah.se/cgi-bin/cread.cgi?/cafe/Stories/humor/SAM-howto.shtml  it works great.  but not if i try to do the same from within a page.

Here is the working counter program

--------------------------------
#!/usr/bin/perl

require "counter.conf";

$pagepath = $ENV{'DOCUMENT_URI'};

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

open(FILE, ">>$counter_file");
close(FILE);

open(FILE, "$counter_file");
@indata = <FILE>;
close(FILE);

$onoff = 0;
open(FILE, ">$counter_file");
foreach $temp (@indata)
{
        chop($temp);
        ($uri, $count) = split(/\|/, $temp);
        if ($uri eq $pagepath) {
                $count++;
                $onoff = 1;
                print FILE "$uri|$count\n";
#               print "$count"; }
}
        else {  print FILE "$uri|$count\n"; }
}
if ($onoff eq 0) {
        print FILE "$pagepath|1\n";
#       print "1"; }
}

close(FILE);
-----------------------------

here is the (troublesome) read program
-----------------------------
#!/usr/bin/perl

require "counter.conf";

$pagepath = $ENV{"QUERY_STRING"};
print "Content-type: text/html\n\n";
open(FILE, ">>$counter_file");
close(FILE);

open(FILE, "$counter_file");
@indata = <FILE>;
close(FILE);

$onoff = 0;
open(FILE, ">$counter_file");
foreach $temp (@indata)
{
        chop($temp);
        ($uri, $count) = split(/\|/, $temp);
        if ($uri eq $pagepath) {
#               $count++;
                $onoff = 1;
                print FILE "$uri|$count\n";
                print "$count"; }
        else {  print FILE "$uri|$count\n"; }
}
if ($onoff eq 0) {
#       print FILE "$pagepath|1\n";
#       print "1"; }
}

close(FILE);

as you can see they are very similar. What i want here is a counter that can count page hits, and a way to display teh count for any given page in a cell in a table in another .html file. All options considered.
0
 
chrisboltCommented:
First, what is the point of these lines:

open(FILE, ">>$counter_file");
close(FILE);

Second, have you considered using the HTTP_REFERER environment variable instead of the QUERY_STRING environment variable? That would eliminate the need for using the query string (or does that hold the referrer to the page calling the script, or the page referring the script? I'll check up on that...)
0
 
chrisboltCommented:
Forget what I said under the Second section, I didn't read your question correctly.

How about using a single CGI script with all of the HTML in it instead of using an SSI page including the CGI output.

The only reason I see why you would want to do it the SSI way would be if you wanted to include multiple page stats on a single page. Is this the way you are planning to do it? If so, that would probably be an inefficient way to do it because of the overhead of starting perl and recompiling the script each time.
0
 
plrCommented:
Hi j2!

In tags like <!--#exec cmd="ping www.microsoft.com" --> you must use it as shell commands witch args. And you cannot see the results of execution this commands.

WBR!
0
 
j2Author Commented:
Sorry, need a sloution to the problem, it can be done.. ive seen it.. but have not been able to "steal" the counter.  I need a cgi program that can read my datafile, chosing which result to display from a argument passed in teh exec line, and return the result to the document.
0
 
j2Author Commented:
chrisbolt: If you can provide me with a working solution (in whatever form it may take) ill give you tons of points.

More background, i want a datafile of somesort, containing the number of pagehits to each page (that part is easy) and i want to display the result in a table such as

Page_one has been read 16 times
Page_two has been read 9 times
Page_three  has been read 34 times.

(generating the number by calling the cgi with the "page path" as an argument to the cgi-exec line.

so, i realize that the re-execution of the perl script introduces overhead, but i have not figured out a better way to do it. Yeah, i've though about cgi-bin generating the entire "table page" but that is a bit "over my head", since i dont reall yknow where to start.
0
 
j2Author Commented:
Ok.. generating the page with a single CGI bin would work. and is prolly a question of it's own. but thsi calls for (even more) background

i have several pages containing the "articles" and i need to generate a table with the following (kind of) layout

Language - Story Name - Author - Date added - # of reads - comment the article

(all 6 fields on a single row in the table)

Language: is represented by the icon of a flag

Story name:  is the "real name" of the article, not the filename (click on it to load the html page holding the article)

Author: is name of author (click to email)

# of reads: (simply "how many times has this article been read)

comment the article: URL to a discussion thread about that article

So, as you can see, it is no small feat collecting all that info.

i suppose one could use a file containing "one data field on each line" like
--------------------------
nameoficonofstory1language
nameofstory1
URLtostory1
authorofstory1
emailtoauthorofstory1
dateaddedstory1
urltoforum1

nameoficonofstory2language
nameofstory2
URLtostory2
authorofstory2
emailtoauthorofstory2
dateaddedstory2
urltoforum2
----------------------

and compile the page from that.. but that is DEFINITELY out of my league.. tho, i have no problem raising the value of the questionm to 1000 points or something. anyone up for grabs?
0
 
plrCommented:
maybe you need the key from my house with money? ;) (c) Ostap Bender.

My advise is: you must set up beforehand results file as you need:

URL|Language|Story_Name|Author|Date_added|counter

and your script will increase the counter, and when you will read results, you must give it all.

0
 
chrisboltCommented:
Okay, I will post a script tomorrow (it's Christmas! :-)
0
 
j2Author Commented:
chrisbolt: Problem solved really. seems the server admin was at fault. so, all of a sudden everything works ... Now.. you really deserver the point all back from the "include virtual" suggestion you made. anyway.. submit something as an answer, and get some points.
0
 
chrisboltCommented:
Okay
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

  • 8
  • 6
  • 2
  • +2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now