Trigger MC CGI with nothing to StandardOut

Sivakatirswami katir at hindu.org
Tue Mar 5 18:20:00 EST 2002


Aloha, 

Since my knowledge of CGI fills a small thimble... this question, ( which
perhaps it more appropriately sent to the Apache listserver/forum, but since
I want to do it from within MC....)

I have a little mc cgi that "rotates" an image by randomly selecting one
from a set of 15 and reading a gif as binary and writing out the file again
under a standard name which is the tag in the HTML that is served. (see
script below). I can trigger the CGI "from home" from within MC using "get
url..." and it works fine. I can also put

www.gurudeva.org/cgi-bin/rotate_taka_art.cgi

into my browser  and it works fine.  But, if I comment out the part  that
serves the image to the browser...(the last three lines of this script) I
will get an apache error... obviously on a GET Apache "demands' that
something be sent to standardOut. What I want to do is eliminate the last
three lines and still be able to trigger the CGI remotely.

Another way to state the problem is: from with MC/REV how to tell a CGI to
execute where that CGI doesn't return anything.. it simply performs an
operation on site. 

OK, some context in case there is an entire better strategy: the goal is to
include a statement in the html form of a index.shtml that is served that
would trigger the CGI
<!--#exec cgi="/cgi-bin/rotate_taka_art.cgi"-->  But, this doesn't work... I
get binary code for the GIF in the place where this is entered, not a .GIF
image... So, I want to "lop off" the last three lines so that when the page
is hit, put the statement at the top of the page and have a normal img src
tag, which goes for the same image, but the CGI will have swapped it for a
new one each time, i.e. the art is "rotated and the next person who uses the
page gets a different image... but, if I lop of the last three lines, apache
doesn't like this either.  I actually solved the problem with a work around
by sending nothing out the pipe... but there are other situations where I
don't want to be forced to send anything to standardOut...

########## rotate_taka_art.cgi ##########
on startup
   set the directory to "../images"
   put random(15) into AumNo
   put "taka_aum_" &AumNo&".gif" into nextAum
   put URL ("binfile:aums/"&nextAum) into temp_image
   put temp_image into URL ("binfile:taka_header_art.gif")
   put "Content-Type: image/gif" & cr
   put "Content-Length:" && the length of temp_image & cr & cr
   put temp_image
end startUp

Wants to become:

on startup
   set the directory to "../images"
   put random(15) into AumNo
   put "taka_aum_" &AumNo&".gif" into nextAum
   put URL ("binfile:aums/"&nextAum) into temp_image
   put temp_image into URL ("binfile:taka_header_art.gif")
end startUp

this work around works also, where send nothing to standard out except a
header and then you can include the exec statement at the top of the HTML
page... but this is very "hokey"
:
#!/export/vhost/org/g/gurudeva/www/public_html/cgi-bin/mc
on startup
   set the directory to "../images"
   put random(15) into AumNo
   put "taka_aum_" &AumNo&".gif" into nextAum
   put URL ("binfile:aums/"&nextAum) into temp_image
   put temp_image into URL ("binfile:taka_header_art.gif")
 put empty into dummyOut
  put "Content-Type: image/gif" & cr
   put "Content-Length:" && the length of dummyOut & cr & cr
   put dummyOut
end startUp


Hinduism Today

Sivakatirswami
Editor's Assistant/Production Manager
katir at hindu.org 
www.HinduismToday.com, www.HimalayanAcademy.com,
www.Gurudeva.org, www.hindu.org

Read The Master Course Lesson of the Day at
http://www.gurudeva.org/lesson.shtml

_______________________________________________
metacard mailing list
metacard at lists.runrev.com
http://lists.runrev.com/mailman/listinfo/metacard



More information about the use-livecode mailing list