[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[eev] basic CGIs

From: Eduardo Ochs
Subject: [eev] basic CGIs
Date: Mon, 20 Jun 2005 19:10:27 -0300

Hi, here's some code that I've been using to (re-)learn about CGIs.
The first block is to be run with F3, the second with F9s.

I've heard wonders about Ruby on Rails, and I'd like to have something
like this for Rails. There's something like this implemented for PHP
already - see:

    (find-eevex "php.e")
    (find-eev "eev-langs.el" "eephp")

By the way, what made me ressurect this code for CGIs was that I
realized that using JavaScript in web pages we could have HTML pages
with hyperlinks that would look nice on a graphical browser (say:
FireFox) and the action of those hyperlinks would be to do something
on a running Emacs. So, I've been working mostly on the "Emacs ->
other programs" direction, but in this case I'm doing smething in the
"FireFox -> Emacs" direction.

A link to

    javascript:e(e('(find-node "(emacs)Lisp Eval")')

is quite readable when displayed on the bottom of the FireFox window
(i.e., at that space where hyperlink targets are shown) and when
followed it would open, say, this page: "(emacs)Lisp Eval")
                                         %-encoded in the right way

and then gnudoit.cgi would verify that the connection comes from and would invoke gnudoit (as the user "edrx") to run
`(find-node "(emacs)Lisp Eval")' in edrx's Emacs session.

Note that we could dispense with the JavaScript and use links whose
targets would be like this: "(emacs)Lisp Eval")

but the "javascript:e('...')" version looks a bit cleaner, and why


# runtmpcgi
# 2005jun15

# «runtmpcgi»
# Taken from:
export EECGIFILE=/usr/lib/cgi-bin/tmp.cgi
export EECGIURL=
function tmpcgi () {
  wget -q -O - $EECGIURL$1 $*[2,-1]
function runtmpcgi () {
  cat     > $EECGIFILE
  chmod 755 $EECGIFILE
  tmpcgi $*
function runperltcgi () {
  { echo '#!/usr/bin/perl'
    echo -E 'print "Content-type: text/plain\n\n";'
    cat } | runtmpcgi $*
function runbashcgi () {
  { echo '#!/bin/bash'
    echo -E 'echo -e "Content-type: text/plain\n"'
    cat } | runtmpcgi $*
function runluacgi () {
  { echo "#!$(which lua50)"
    echo -E 'print("Content-type: text/plain\n")'
    cat } | runtmpcgi $*


# cgis
# 2005jun15

# (find-efunction 'eehtml)
# (find-angg ".zshrc" "runtmpcgi")
# (find-fline "~/.xchat2/downloads/")

 (eechannel-xterm "A")
sudo rm -v $EECGIFILE
sudo touch $EECGIFILE

echo date | runbashcgi
echo set  | runbashcgi
echo set  | runbashcgi '?foo'
echo '
' | runbashcgi '?%28find-file%20%22%2Ftmp%2Ffoo%22%29'

echo 'print("hi")' | runluacgi
echo '
  hextochar = function (s) return string.char(tonumber(s, 16)) end
  unescape  = function (s) return string.gsub(s, "%%(%x%x)", hextochar)
  q = unescape(os.getenv("QUERY_STRING"))
' | runluacgi '?A%40%20B'


# (find-Lua50ref "")
# (find-Lua50ref "character class" "%x")
# (find-Lua50ref "string.gsub (s, pat, repl [, n])" "os.getenv")
# (find-Lua50ref "os.execute (command)")
# (find-node "(libc)Running a Command")

-- - Send your email first class

reply via email to

[Prev in Thread] Current Thread [Next in Thread]