
cgi-related help needed
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
-
- Posts: 344
- Joined: Tue Feb 24, 2009 6:14 pm
- Contact:
cgi-related help needed
Is there a nice list somewhere that displays all compatible commands, functions etc. with the Rev CGI with definitions? I've tried looking at the Dictionary included with Rev and also the online dictionary, on the online dictionary, it dims out the commands that aren't compatible with revServer. I took a look at it and saw that launch or launch URL seems to be supported by revServer. I tried it on mine but it just displayed a blank page. Is there a way to launch an URL via CGI? And is there even a list as I described it above... More power guys and uhh, btw, my hosting is free.... 

-
- VIP Livecode Opensource Backer
- Posts: 10045
- Joined: Sat Apr 08, 2006 7:05 am
- Contact:
Re: cgi-related help needed
I'm not sure what "launch url" would be expected to do on a server; most server processes are easily run with the "shell" function or "open process".
For example, here's a handler from my CGI library for sending email using the mail program normally installed on Linux servers:
To answer your larger question, most of the things you'd want to do with a CGI are supported, working with text, reading/writing files, arrays, etc. Things related to the GUI (windowShape, gradients, the "go" command, etc.) won't work because there's no GUI in the faceless server mode.
Tip: one of the cool things you can do with a CGI script is use libraries via the "start using" command. This makes it simple to write all manner of handy commands and functions that all of your CGIs can use over and over without having to copy them to each CGI script.
For example, here's a handler from my CGI library for sending email using the mail program normally installed on Linux servers:
Code: Select all
on cgiSendMail pTo, pFrom, pSubject, pMessage
put "/usr/sbin/sendmail -t" into tSendMailProg
open process tSendMailProg for write
write "From:" && pFrom & cr to process tSendMailProg
write "To:" && pTo & cr to process tSendMailProg
write "Subject:" && pSubject & cr & cr to process tSendMailProg
write pMessage & cr to process tSendMailProg
close process tSendMailProg
wait until tSendMailProg is not among the lines of the openProcesses
end cgiSendMail
Tip: one of the cool things you can do with a CGI script is use libraries via the "start using" command. This makes it simple to write all manner of handy commands and functions that all of your CGIs can use over and over without having to copy them to each CGI script.
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn
-
- Posts: 344
- Joined: Tue Feb 24, 2009 6:14 pm
- Contact:
Re: cgi-related help needed
Thanks for the prompt reply, I was thinking of the launch url command as something that could hopefully open a new webpage without requiring the user to click on a link?
- and I use the start using or the library command on my CGI scripts and reference it to revStacks?FourthWorld wrote:Tip: one of the cool things you can do with a CGI script is use libraries via the "start using" command. This makes it simple to write all manner of handy commands and functions that all of your CGIs can use over and over without having to copy them to each CGI script.
-
- VIP Livecode Opensource Backer
- Posts: 10045
- Joined: Sat Apr 08, 2006 7:05 am
- Contact:
Re: cgi-related help needed
Yes, to include any stack as a library your CGI script calls it using the same syntax as in a standalone:
start using "MyLibrary.rev"
Note that the path there assumes the stack is in the same folder as the CGI. When a CGI runs, the defaultFolder is the folder in which the CGI resides. So if your library stack is in a subfolder named "libs", for example, you would use:
start using "/libs/MyLibrary.rev"
As for opening a new window, you can do that by setting the location with "_blank" in the target attribute. But remember how CGIs work as you plan your interface in the client: when a CGI is called, whatever it returns replaces the current page. If you want to keep your current page and have the results in a new window, you might add a target attribute to the link that calls the CGI. If you want to overwrite only a portion of the page, you might consider putting that portion in an iFrame, as I did at mumblo.com.
start using "MyLibrary.rev"
Note that the path there assumes the stack is in the same folder as the CGI. When a CGI runs, the defaultFolder is the folder in which the CGI resides. So if your library stack is in a subfolder named "libs", for example, you would use:
start using "/libs/MyLibrary.rev"
As for opening a new window, you can do that by setting the location with "_blank" in the target attribute. But remember how CGIs work as you plan your interface in the client: when a CGI is called, whatever it returns replaces the current page. If you want to keep your current page and have the results in a new window, you might add a target attribute to the link that calls the CGI. If you want to overwrite only a portion of the page, you might consider putting that portion in an iFrame, as I did at mumblo.com.
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn