Solved

Execution of "embedded" args?

Posted on 1998-12-21
18
271 Views
Last Modified: 2013-12-25
<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
Comment
Question by:j2
  • 8
  • 6
  • 2
  • +2
18 Comments
 
LVL 7

Expert Comment

by:faster
ID: 1830232
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
 
LVL 84

Expert Comment

by:ozo
ID: 1830233
<!--#exec cmd="QUERY_STRING='/cafe/Stories/humor/SAM-howto.shtml'; /home/j2/public_html/cgi-bin/cread.cgi"-->
0
 
LVL 12

Author Comment

by:j2
ID: 1830234
Thats definitely the wrong answer.
0
 
LVL 12

Author Comment

by:j2
ID: 1830235
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
 
LVL 12

Author Comment

by:j2
ID: 1830236
ozo: however, that also failed. still says "an error occured while processing this directive"




0
 
LVL 2

Expert Comment

by:chrisbolt
ID: 1830237
Try this:

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

Expert Comment

by:chrisbolt
ID: 1830238
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
 
LVL 12

Author Comment

by:j2
ID: 1830239
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
 
LVL 2

Expert Comment

by:chrisbolt
ID: 1830240
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
3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

 
LVL 2

Expert Comment

by:chrisbolt
ID: 1830241
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
 

Expert Comment

by:plr
ID: 1830242
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
 
LVL 12

Author Comment

by:j2
ID: 1830243
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
 
LVL 12

Author Comment

by:j2
ID: 1830244
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
 
LVL 12

Author Comment

by:j2
ID: 1830245
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
 

Expert Comment

by:plr
ID: 1830246
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
 
LVL 2

Expert Comment

by:chrisbolt
ID: 1830247
Okay, I will post a script tomorrow (it's Christmas! :-)
0
 
LVL 12

Author Comment

by:j2
ID: 1830248
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
 
LVL 2

Accepted Solution

by:
chrisbolt earned 400 total points
ID: 1830249
Okay
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Preface This is the third article about the EE Collaborative Login Project. A Better Website Login System (http://www.experts-exchange.com/A_2902.html) introduces the Login System and shows how to implement a login page. The EE Collaborative Logi…
Styling your websites can become very complex. Here I'll show how SASS can help you better organize, maintain and reuse your CSS code.
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …

911 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now