Solved

Execution of "embedded" args?

Posted on 1998-12-21
18
276 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
DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

 
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
 
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

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

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

Suggested Solutions

Styling your websites can become very complex. Here I'll show how SASS can help you better organize, maintain and reuse your CSS code.
Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
HTML5 has deprecated a few of the older ways of showing media as well as offering up a new way to create games and animations. Audio, video, and canvas are just a few of the adjustments made between XHTML and HTML5. As we learned in our last micr…
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

777 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