>My friendly sysadmin told me about this.
>1 Wherever you keep your home page type this:
> mknod count.html p
> (of course you can call count.html something else if you want)
As Ross and I subsequently discovered, the one thing that this doesn't
allow you to do is to pass CGI headers to the server, so "Location: "
headers won't work. This is because the server isn't expecting a script in
that file, so it doesn't parse for CGI headers.
Everything else will work though.
Enjoy :-)
Alex French
LIFE version 0.9 beta -- Unregistered Copy
Contact g...@heaven.com for bug reports and pricing information.
A few things that need to be clarified:
1. You need to keep the count program running all the time. If the system
reboots, restart it. Otherwise, it won't work.
2. You won't get the CGI interface, (I think) so you're pretty limited in
what you can do.
3. Many sysadmins disapprove of this kind of thing. You can open up LOTS
of security holes by screwing up code, and it eats up a process table
entry. Do it on a machine I administer, and it might result in your
untimely death :)
4. It's relatively easy hack to the system to not read from named pipes
(Apache - anyone listening?)
5. It only works if you can access the machine which runs the server, since
the little daemon needs to be running on the same computer as httpd.
For instance, if your site has a seperate machine like www.foo.com
which you can't log into - you're out of luck.
Basically, if you're serious about web programing, buy your sysadmin a drink.
-Mitchell Blank
mi...@cs.wisc.edu
1 Wherever you keep your home page type this:
mknod count.html p
(of course you can call count.html something else if you want)
2 compile the thing below
gcc -o count thing.c
3 run count from your web home page directory in the background.
(you can run it from anywhere if you change from a relative to
absolute pathname in the program below).
count &
4 check it out with a web browser
lynx count.html
#include <stdio.h>
main()
{
FILE *fp;
int i;
for( i = 0 ; ; i++ )
{
fp = fopen("count.html","w");
fprintf(fp,"<HEADER>Ross's Counting page.\n</HEADER>");
fprintf(fp,"<BODY>You are person number %d to read this.</BODY>"
,i);
fclose(fp);
sleep(3);
}
}
--
"Unix... I know this!"
Web Page http://www.maths.tcd.ie/~chandler
: #include <stdio.h>
How can you get this to work with a shell script?
Mark Sztainbok
(mjs...@ccds.cc.monash.edu.au)
[ Description of using a named pipe to provide pseudo-CGI capability. ]
>How can you get this to work with a shell script?
#!/bin/sh
while /bin/true; do
( command1
command2
... ) > filename.html
done
--
Barry Margolin
BBN Planet Corporation, Cambridge, MA
bar...@bbnplanet.com
I'm missing something; this seems all too simple. I've read "The HTML
Sourcebook" and have perused the sites it lists regarding CGI and I still
am missing one piece: how do you get this little "counter" to execute when
someone enters your home page?
The stats that seem to be in so many home pages seemed a simple way to get
started with cgi tools, but I don't quite understand how, when a user
accesses your home page, *but hasn't selected any refs yet*, the stats cgi
tool can get run to update the number of accesses to your home page.
The above script just creates an html doc on the fly. You need this to
update the "count" of accesses and then the user can select the stats doc
(which this script updated). The question is how to get the update script
to run before anything else gets executed.
If there are online docs on this subject, please point me in the right
direction. Thanks.
--
Michael J. Hammel @ Xinside| Silent enim leges inter arma.
mjha...@csn.net | (Laws are dumb in the midst of arms.)
http:/www.csn.net/~mjhammel|
#include <std/disclaim> | Cicero, "Pro Milone"
>In article <3nof99$q...@bell.maths.tcd.ie>,
>Ross Chandler <chan...@maths.tcd.ie> wrote:
>>My friendly sysadmin told me about this.
>>
>>1 Wherever you keep your home page type this:
>> mknod count.html p
[4.5 correct points deleted]
>Basically, if you're serious about web programing, buy your sysadmin a drink.
I never said it was ideal. I already have cgi-bin permission.
Ross
p.s. Remember it was my sysadmin that told me about this because in certain
certain circumstances this is a better way of doing things.
: I'm missing something; this seems all too simple. I've read "The HTML
: Sourcebook" and have perused the sites it lists regarding CGI and I still
: am missing one piece: how do you get this little "counter" to execute when
: someone enters your home page?
: The stats that seem to be in so many home pages seemed a simple way to get
: started with cgi tools, but I don't quite understand how, when a user
: accesses your home page, *but hasn't selected any refs yet*, the stats cgi
: tool can get run to update the number of accesses to your home page.
: The above script just creates an html doc on the fly. You need this to
: update the "count" of accesses and then the user can select the stats doc
: (which this script updated). The question is how to get the update script
: to run before anything else gets executed.
Because you start the script yourself and it goes into an infinite loop.
It hangs the first time it tries to print the named pipe "filename.html",
and then waits for someone to access the named pipe. As soon as someone
does, it is able to continue its work down to the ")" at which time
it closes the first version of the document, returns to the top of the
script, opens the second version of the document, and hangs again.
What I don't know is what happens if two people access the pipe at the
same time. Will one person get exclusive access to it until they've
read the whole file or will both people get bits and pieces of the file?