Re: Sjoerd to the cgi rescue -- (was) Re: CGI nightmares

2001-06-08 Thread Nicolas Cueto

Hi again,

I solved my own questions!

Sorry if the following rehashes all too basic stuff but, in case someone
else trying to enable cgi on a homeserver thru a Win32&Apache&mc mix tunes
in, here are the final, magically simple configurations:

(1) mc.exe does not have to be in Apache's cgi-bin folder. Instead, put it
in "C:/usr/bin", and make sure that, in turn, the opening line (aka, the
shebang line) of your cgi scripts read "#!C:/usr/bin/mc" (without the
quotation marks)

(2) scripts can be in .txt form but, during saving, ensure to append a
".cgi" suffix

(3) store the scripts in the cgi-bin folder which Apache creates during
installation (not in "usr/bin")

(4) in Apache's htppd.conf file (aka "the configuration file"), (i) set
ScriptAlias to the cgi-bin folder's path (in my case, 'ScriptAlias /cgi-bin/
"C:Program Files/Apache/cgi-bin/" '), and (ii) uncomment (remove the hash
mark "#") from the line "# AddHandler cgi-script .cgi"

PLUS, I had to modify the "helloworld" script from Simon Lord's
www.mctools.org thus:

#!C:/program files/Apache/cgi-bin/mc
on startup
put "Hello world" into var1
# Add the following, the very minimum required for
# a browser to recognize a text file.
# MODIFICATION: instead of 'put "Content-Type: text/plain" ',
# which was returning a text file consisting of the line "Hello
world"...
put "Content-Type: text/html" & cr
put "Content-Length:" && the length of var1 & cr & cr
# now send it back to the browser
put var1
end startup

That's it! There were, of course, many other preliminary steps, about which,
if you're curious/at wits end, I'd be glad to help out with.

Cheers,

Nicolas R Cueto



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




Sjoerd to the cgi rescue -- (was) Re: CGI nightmares

2001-06-08 Thread Nicolas Cueto

Hi.

Finally got my Apache-based homeserver to deliver a static website :-). Now,
onto cgi via mc :-(

Sjoerd Op 't Land (thankfully!) wrote:

> You need to have MC installed at the server.

"Installed" means placing mc.exe, mc.home, mc.help, etc, in the cgi-bin
folder which is designated by the server, right?

> Make a text file with your
> script (like the above), and upload it to the server.

A text file? I'm confused. I thought I had to save an mc stack into my cgi
bin, perhaps appending an .mt or .cgi  suffix to its title.

FWIW, I tried all the possible variations -- text form and stack form with a
variety of file types suffixes -- by working off Simon Lord's "helloworld"
script (below)-- i.e., (1) made an mc stack of the script and then saved it
under three different labels; 2. made a text file with that script and,
again, labelled it three ways.

The result: my server seemed to find the "helloworld" file but could not
execute it. Instead, a 500 Internal Server Error was returned, which my
Apache error log specified as "couldn't spawn child process".

> Don't forget to set
> the permissions to "755", use chmod.

Could this be the problem? If so, how do I set permissions with an FTP (I
have LeapFTP and FreeFTP, but neither mentions chmod or 755)? Or are
permissions not an issue if the files are running off my own server?

I'll of course head back to the archives. In the meantime, I'd appreciate
the handholding.

Thank you.

Nicolas R Cueto

here's my helloworld pirating of Simon Lord's

#!C:/program files/Apache/cgi-bin/mc
on startup
  put "Hello world" into var1

  # Add the following, the very minimum required for
  # a browser to recognize a text file.
  put "Content-Type: text/plain" & cr
  put "Content-Length:" && the length of var1 & cr & cr

  # now send it back to the browser
  put var1
end startup




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




Re: CGI nightmares

2001-06-06 Thread Sjoerd Op 't Land

Raymond E. Griffith wrote/ schreef:

> on 6/06/2001 12:01 AM, "Sjoerd Op 't Land" <[EMAIL PROTECTED]> was very
> helpful
> 
> Thank you. This is helpful. But I am going to expose my great ignorance here
> (some things I do mighty well, but this is not one of them).
> 
> This is an .mt script, right? So what is involved in putting up a MetaCard
> cgi? Will I have to have a version of MetaCard on the server? How do I
> format the MetaCard stack that contains the cgi script?
CGI works like this:
- web client sends some data from (e.g.) his Internet browser
- server processes it in some way (e.g. a .mt script)
- web client receives the output from this process

So, a .mt script is just one of the (very) many ways to process the data. A
.mt script looks like this:

#!/usr/bin/mc
-- so that the server knows that this script has to be executed
-- with MetaCard
on startup
  -- everything between 'on startUp' and 'end startUp' will be executed
  # first make an array qParameter with all the arguments
  # as key
  set itemdel to "="
  put replaceText($QUERY_STRING,"&",return) into tQuery
 repeat with i = 1 to the number of lines in tQuery
put urlDecode(item 2 of line i of tQuery) into qParameter[item 1 of line
i of tQuery]
  end repeat
  -- this is just a handy snippet to extract the arguments from the query
  -- string. Example:
  -- $QUERY_STRING = "name=Sjoerd%20Op%20%35t%20Land&age=14&vote=4"
  -- result: qParameter["name"] = "Sjoerd Op 't Land"
  -- qParameter["age"]  = "14"
  -- qParameter["vote"] = "4"

  -- generate the content, you can put whatever you want to do here
  put "This is a test" into buffer
  
  -- write minimal set of HTTP headers to stdout
  -- (if you use 'put' here without a destination, it goes to the 'stdout'
  -- i.e. the web client)
  put "Content-Type: text/plain" & cr
  -- use "text/html" if you want to output HTML, or
  -- "image/jpeg" if you want to output a JPG file for example
  put "Content-Length:" && the length of buffer & cr & cr
  put buffer
end startup

You need to have MC installed at the server. Make a text file with your
script (like the above), and upload it to the server. Don't forget to set
the permissions to "755", use chmod.

If you don't know how to configure all this, and just want to test some CGI
scripts, go to http://www.mctools.org/ and create a free MT CGI account.
Read the instructions!

> Now at the moment, I am using Tripod for my server. That will change, later,
> but for right now it is available and I need to use it.
> 
> All this is very new to me, but absolutely necessary for the person I am
> working with. 
> 
> Thanks
> 
> Raymond
Hope this helps,
Sjoerd


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




Re: CGI nightmares

2001-06-06 Thread Raymond E. Griffith

on 6/06/2001 12:01 AM, "Sjoerd Op 't Land" <[EMAIL PROTECTED]> was very
helpful

Thank you. This is helpful. But I am going to expose my great ignorance here
(some things I do mighty well, but this is not one of them).

This is an .mt script, right? So what is involved in putting up a MetaCard
cgi? Will I have to have a version of MetaCard on the server? How do I
format the MetaCard stack that contains the cgi script?

Now at the moment, I am using Tripod for my server. That will change, later,
but for right now it is available and I need to use it.

All this is very new to me, but absolutely necessary for the person I am
working with. 

Thanks

Raymond

> 
> Raymond E. Griffith wrote/ schreef:
> 
>> I have been wrestling with the POST command for some time now with little
>> success.
>> 
>> Here is what I want to do. I want to have a MetaCard/Revolution program sent
>> a POST to a URL containing field data. The URL is a CGI that should receive
>> the data and email it back to me.
>> 
>> Is this so hard to do?
> Difficulty is relative, but... I think its absolutely doable:
> WARNING: This is from the top of my head, so...
> 
> The CGI script:
> 
> #!/usr/bin/mc
> on startup
> # first make an array qParameter with all the arguments
> # as key
> set itemdel to "="
> put replaceText($QUERY_STRING,"&",return) into tQuery
> repeat with i = 1 to the number of lines in tQuery
> put urlDecode(item 2 of line i of tQuery) into qParameter[item 1 of line
> i of tQuery]
> end repeat
> 
> # store the mail body in a temporary file
> put qParameter["message"] into url "file:email.txt"
> 
> # generate the shell to be executed
> put "mail -s" && quote & qParameter["subject"] & quote && qParameter["to"]
> && "< email.txt" into eCommand
> 
> # execute the mail command
> put shell(eCommand) into buffer
> 
> #write minimal set of HTTP headers to stdout
> put "Content-Type: text/plain" & cr
> put "Content-Length:" && the length of buffer & cr & cr
> put buffer
> end startup
> 
> 
> The MC script:
> 
> post "message=" & urlEncode(field "message body") & "&to=" & urlEncode(field
> "to") & "&subject=" & urlEncode(field "subject") to
> "http://www.mctools.org/~rgriffit/sendmail.cgi";
> answer it
> 
> Or something like this...
>> I'm having a hard time not saying bad words over my lack of success.
>> *&%%$**!!!
>> 
>> Any kind suggestions would be appreciated.
>> 
>> Raymond 
> Hope this helps,
> Sjoerd


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




Re: CGI nightmares

2001-06-06 Thread Richard Herz

Raymond E. Griffith wrote:

>I have been wrestling with the POST command for some time now with little
>success.

I had to set the httpheaders in my MC stack before "post" or my PERL cgi
script couldn't read the input buffer from the post.  Currently I set
httpheaders to

set the httpHeaders to \
"Content-type: application/x-www-form-urlencoded"&return

I got this from earlier posts to this list and haven't looked at other
options.  Now the cgi script reads the text posted and writes it to a file
on the server.  I can't get the parsing PERL script someone gave me to do
any parsing yet.

Rich Herz <[EMAIL PROTECTED]>


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




Re: CGI nightmares

2001-06-06 Thread Pierre Sahores

Hi Raymond,

See, about that, the previous Michael Kann's mails (in the list archive, at
) Michael did all the
tests about that ;-)
 
> I have been wrestling with the POST command for some time now with little
> success.
> 
> Here is what I want to do. I want to have a MetaCard/Revolution program sent
> a POST to a URL containing field data. The URL is a CGI that should receive
> the data and email it back to me.
> 
> Is this so hard to do?
> 
> I'm having a hard time not saying bad words over my lack of success.
> *&%%$**!!!
> 
> Any kind suggestions would be appreciated.
> 
> Raymond
> 
> Archives: http://www.mail-archive.com/metacard@lists.runrev.com/
> Info: http://www.xworlds.com/metacard/mailinglist.htm
> Please send bug reports to <[EMAIL PROTECTED]>, not this list.

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/metacard@lists.runrev.com/
Info: http://www.xworlds.com/metacard/mailinglist.htm
Please send bug reports to <[EMAIL PROTECTED]>, not this list.




Re: CGI nightmares

2001-06-06 Thread Sjoerd Op 't Land

Raymond E. Griffith wrote/ schreef:

> I have been wrestling with the POST command for some time now with little
> success.
> 
> Here is what I want to do. I want to have a MetaCard/Revolution program sent
> a POST to a URL containing field data. The URL is a CGI that should receive
> the data and email it back to me.
> 
> Is this so hard to do?
Difficulty is relative, but... I think its absolutely doable:
WARNING: This is from the top of my head, so...

The CGI script:

#!/usr/bin/mc
on startup
  # first make an array qParameter with all the arguments
  # as key
  set itemdel to "="
  put replaceText($QUERY_STRING,"&",return) into tQuery
 repeat with i = 1 to the number of lines in tQuery
put urlDecode(item 2 of line i of tQuery) into qParameter[item 1 of line
i of tQuery]
  end repeat

  # store the mail body in a temporary file
  put qParameter["message"] into url "file:email.txt"

  # generate the shell to be executed
  put "mail -s" && quote & qParameter["subject"] & quote && qParameter["to"]
&& "< email.txt" into eCommand
  
  # execute the mail command
  put shell(eCommand) into buffer
  
  #write minimal set of HTTP headers to stdout
  put "Content-Type: text/plain" & cr
  put "Content-Length:" && the length of buffer & cr & cr
  put buffer
end startup


The MC script:

post "message=" & urlEncode(field "message body") & "&to=" & urlEncode(field
"to") & "&subject=" & urlEncode(field "subject") to
"http://www.mctools.org/~rgriffit/sendmail.cgi";
answer it

Or something like this...
> I'm having a hard time not saying bad words over my lack of success.
> *&%%$**!!!
> 
> Any kind suggestions would be appreciated.
> 
> Raymond 
Hope this helps,
Sjoerd


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




CGI nightmares

2001-06-05 Thread Raymond E. Griffith

I have been wrestling with the POST command for some time now with little
success.

Here is what I want to do. I want to have a MetaCard/Revolution program sent
a POST to a URL containing field data. The URL is a CGI that should receive
the data and email it back to me.

Is this so hard to do?

I'm having a hard time not saying bad words over my lack of success.
*&%%$**!!!

Any kind suggestions would be appreciated.

Raymond 

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