Sivakatirswami a �crit :
> 
> Can I write an MC "cgi" that will simply trigger a stack on a distant site?

Yes. You can have both an mc-based browser or html forms speaking to the server.
But the first way will only run fine if the mc-based browser speak directly to
an mc vpn deamon, not to a standard httpd (i.e.: Apache, WebStar, IIS...).

> i.e. I have MC running on a distant server, running Apache over Linux, where
> I have FTP access and MC is enabled also to run cgi's but I don't have
> "terminal GUI interface" access.

It's a way to have mc running as a web application server (WAS, i.e.: Zope or
ColdFusion) instead of just a cgi interpreter. If you use this way, you will be
able to run your MC-based WAS in both root-console mode (on a "<= 1024 socket
port") and standard user-x-windows mode (on a "> 1024 socket port"). If the
first mode is prefered as the "production" mode, the second mode is usefull as
the "programming & debugging" mode (you can use the "put" and "answer" commands
to parse the code to debug).
Be just carefull not to use "on idle" handlers in your WAS as far this is only
working in graphical mode, not in the console mode.

> It would seem a lot easier to build certain tools as stacks, ftp the stack
> to the site and then "run it" some how. These are operations where I am not
> reading standardIN and not processing standardOut back to the browser, but
> doing global text manipulations on files on the server.

The same as above ;-)

> But the trick is to "trigger" it...i.e. make it execute.
> 
> could it really be as simple as putting this in a browser:
> 
> "http://www.myDistantDomain/cgi-bin/runStack.cgi";
> 
> where the .cgi script is just:
> 
> #!/usr/local/bin/mc
> 
> on start up
>   send mouseup to button "SearchReplace" of stack
> "/tmp/mcstacks/siteAdmin.mc"
> end startup

I never found the way, for yet, to have the MC-based WAS linked to Apache trough
an ".mc/.mt" cgi based script. I use an ".php" based script, renamed as ".xml",
instead and it works fine :

<?

if ($REQUEST_METHOD == POST) {

        $headers = $HTTP_POST_VARS;
        while (list($header, $value) = each($headers)) $exAE .= "$header=$value&";
        $exAE = urlencode($exAE);

        $connection = fsockopen("localhost", "567",  &$error_number,
&$error_description, "30");      
        if ($connection) {
                set_socket_blocking($connection, true);
                fputs($connection,"");
                fputs($connection,"$exAE"."\r\n");
                fpassthru($connection);
                }
        else {
                $connection = fsockopen("localhost", "4567",  &$error_number,
&$error_description, "30");      
                if ($connection) {
                        set_socket_blocking($connection, true);
                        fputs($connection,"");
                        fputs($connection,"$exAE"."\r\n");
                        fpassthru($connection);
                }
                else print("erreur num�ro $error_number ($error_description)<BR>\n");
        }
}

else print("<HTML><HEAD><TITLE>ERROR: File Not Found</TITLE></HEAD>".
        "<BODY background='/gif/fond-maison.gif'><H1>File Not Found</H1><P>".
        "<H3>The file you have requested does not exist on this
server.</H3></BODY></HTML><BR>\n");

?>

If you want to use this MC-based WAS way, just create a new stack and put this
in the stack script :

on newconnect s
  read from socket s for 1 line with message "serverread"
end newconnect

on serverread x,y
  global PostIn,Retour,Lepath
  put urldecode(y) into PostIn
  put cr into char (length(PostIn))-1 to (length(PostIn)) of PostIn
  put empty into Retour
  set itemdelimiter to "&"
  doswitcher
  write Retour to socket x
  close socket x
end serverread

on socketTimout
end socketTimout

on doswitcher
  global PostIn,Retour
  set itemDelimiter to "&"
  if char 1 to 6 of item 1 of PostIn is "hello="
  then hellotest
end doswitcher

on PreOpenStack
  global Masq,AccPpx,Lepath
  put " Please, wait. WMC server loading..."
  set twelveHourTime to false
  put "WMC TCP/IP SEARCH/DB/APP'S server up since" && the short date & "," &&
the short time into binfo
  # put "/usr/local/httpd/w-max/iassd/" into Lepath
  # put url (Lepath & "ia9312.html") into Masq # store your html headers/footers
there
  # open file Lepath & "COLia931.txt" for read # load the needed data as global
vars
  # read from file Lepath & "COLia931.txt" until eof
  # put it into AccPpx
  # put " " & the result after pboot # test the path
  # close file Lepath & "COLia931.txt"
  put " eof" into pboot # to comment if you need to uncomment the above lines
  set the socketTimeoutInterval to "10" # don't forget !
  if the windows is "wasstack" # the default name of your was main stack
  then accept connections on port "567" with message "newconnect" # console mode
  else accept connections on port "4567" with message "newconnect" # x-windows
mode
  replace " eof" with "" in pboot
  if the num of words in pboot > 0
  then put "WMC not up :" & pboot
  else put binfo
end PreOpenStack

on HelloTest
  global Retour
  put "<HTML><BODY><FORM> into Retour
  put "<table border='0' cellpadding='0' cellspacing='5' width='100%'
bgcolor='#EEE8AA'><tr>" & \
      "<td align='center'><font size='2'><B>Hello world
!</B></font></td></tr></table>" after Retour
  put "</FORM></BODY></HTML>" after Retour
end HelloTest


3.- ... and don't forget to add :

<FORM ACTION="wmc.xml" METHOD="POST">
<INPUT TYPE=HIDDEN NAME="hello" VALUE="1">

to your HTML WAS querying form.

> Well, of course I will just go ahead and test this myself, but then maybe
> someone has already been there, done that and has useful advice?

If there is others usables ways to get fine Web Apps running, i prefer, for
myself, the MC way because MC is able to serve VPN apps too, because MC is lots
more powerfull than Java, Python, Perl, etc...

> Or, is there a way to  "talk to" the "siteAdmin.mc" stack via telnet?
> kind of like a distant message box:

Please !?? Do never talk to a distant server in using the unsecure Telnet
protocol. Install and use an SSH deamon instead to stop, start or reboot your mc
app... 

> "send mouseup to button 1 of stack "/tmp/mcstack/stackAdmin.mc"

To play this way, just remember that "...the first way will only run fine if the
mc-based browser speak directly to an mc vpn deamon".

> thanks!
> 
> Hinduism Today
> 
> Sivakatirswami
> Editor's Assistant/Production Manager
> [EMAIL PROTECTED]
> www.HinduismToday.com, www.HimalayanAcademy.com,
> www.Gurudeva.org, www.hindu.org
> 
> Archives: http://www.mail-archive.com/[email protected]/
> Info: http://www.xworlds.com/metacard/mailinglist.htm
> Please send bug reports to <[EMAIL PROTECTED]>, not this list.

Hope this help ;-)

Regards, Pierre Sahores

WEB & VPN applications & databases servers
Inspection acad�mique de Seine-Saint-Denis
Qualifier & produire l'avantage comp�titif

Archives: http://www.mail-archive.com/[email protected]/
Info: http://www.xworlds.com/metacard/mailinglist.htm
Please send bug reports to <[EMAIL PROTECTED]>, not this list.

Reply via email to