Mailing List Archive: 49091 messages
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search
 

Calling a Rebol Script form a CGI

 [1/14] from: pwawood:gmai:l at: 27-Dec-2008 13:36


I would like to call a Rebol script to do some housekeeping from a Rebol CGI but when I try I have a problem that the output from the called script is appended to the output of the CGI script. Here is the cgi script: #!/Applications/Rebol/rebol -cs REBOL [] print "Content-type: text/html^/" print [<HTML><BODY>] print ["From the CGI script"] print [</BODY></HTML>] call "/Applications/Rebol/rebol -cs called.r" Here is the called script: Rebol [] print "From the called script" Here is the output received by the browser: <HTML> <BODY> From the CGI script </BODY> </HTML> From the called script Any suggestions? Regards Peter

 [2/14] from: compkarori:g:mail at: 27-Dec-2008 7:35


Why are you starting another interpreter with 'call?? why not just do %called.r ? On Sat, Dec 27, 2008 at 6:36 PM, Peter W A Wood <pwawood-gmail.com> wrote:
> I would like to call a Rebol script to do some housekeeping from a > Rebol CGI but when I try I have a problem that the output from the
<<quoted lines omitted: 21>>
> To unsubscribe from the list, just send an email to > lists at rebol.com with unsubscribe as the subject.
-- Graham Chiu http://www.synapsedirect.com Synapse - the use from anywhere EMR.

 [3/14] from: dhsunanda:gmai:l at: 27-Dec-2008 8:36


One possibility is to redefine 'print before the call: saved-print: get in system/words 'print print: func [data][] ----code here to call other script----- set in system/words 'print :saved-print You may also need to use the same trick on 'prin and 'probe. The replacement function could do something other than discard the output -- for example, it could write it to a log file. Sunanda

 [4/14] from: compkarori:gmai:l at: 27-Dec-2008 11:36


Sunanda Redefining 'print in the main script will not help as Peter is starting a new Rebol process to run the script. I presume output is going to the browser because he's using the -c flag .... but from what I can understand, he doesn't really want to run it as cgi. On Sat, Dec 27, 2008 at 9:36 PM, Sunanda <dhsunanda-gmail.com> wrote:
> One possibility is to redefine 'print before the call: > saved-print: get in system/words 'print
<<quoted lines omitted: 8>>
> To unsubscribe from the list, just send an email to > lists at rebol.com with unsubscribe as the subject.
-- Graham Chiu http://www.synapsedirect.com Synapse - the use from anywhere EMR.

 [5/14] from: dhsunanda:gmai:l at: 27-Dec-2008 10:36


Graham:
> Redefining 'print in the main script will not help as Peter is > starting a new Rebol process to run the script.
Good point! Thanks. Just trying to rescue my suggestion in another way.... ...He cold have a user.r in the folder as the target version of Core that derails 'print in the same way. Sunanda.

 [6/14] from: santilli::gabriele::gmail::com at: 27-Dec-2008 12:23


On Sat, Dec 27, 2008 at 6:36 AM, Peter W A Wood <pwawood-gmail.com> wrote:
> call "/Applications/Rebol/rebol -cs called.r"
I assume you are on OSX, or some other Unix. You'll want to try something like: call "/Applications/Rebol/rebol -qws called.r >/dev/null </dev/null" If the script output is of any importance, you'll want to redirect it to a log file instead, eg. call "/Applications/Rebol/rebol -qws called.r
>>/path/to/logfile.txt </dev/null"
(The </dev/null is probably unnecessary.) HTH, Gabriele.

 [7/14] from: andreas::bolka::gmx::net at: 28-Dec-2008 0:29


Excerpts from Peter W A Wood's message of Sat Dec 27 06:36:31 +0100 2008:
> I would like to call a Rebol script to do some housekeeping from a > Rebol CGI but when I try I have a problem that the output from the > called script is appended to the output of the CGI script.
[...]
> Any suggestions?
Have a look at call/output. -- Regards, Andreas

 [8/14] from: pwawood:gma:il at: 28-Dec-2008 13:27


Graham
> Why are you starting another interpreter with 'call?? > > why not just > > do %called.r?
Two reasons. The first is not wanting to delay the transmission of the output from the cgi script to the browser. The second is wanting to view the output from the called script during testing. Regards Peter

 [9/14] from: pwawood:g:mail at: 28-Dec-2008 13:30


Graham
> I presume output is going to the browser because he's using the -c > flag .... but from what I can understand, he doesn't really want to > run it as cgi.
The -c option simply suppresses the Rebol "banner". Here is the output sent to the browser when the -c option is not specified: From the CGI script REBOL/Core 2.7.5.2.4 (4-Mar-2008) Copyright 2008 REBOL Technologies REBOL is a Trademark of REBOL Technologies All rights reserved. Component: "REBOL Mezzanine Extensions" 1.2.0 Component: "REBOL Internet Protocols" 1.71.0 Finger protocol loaded Whois protocol loaded Daytime protocol loaded SMTP protocol loaded ESMTP protocol loaded POP protocol loaded IMAP protocol loaded HTTP protocol loaded FTP protocol loaded NNTP protocol loaded Component: Command Shell Access 1.9.0 Component: "System Port" 1.4.0 Script: Reborg-user.r (21-Oct-2005) Script: "mock-send.r" (11-Aug-2005) Script: "Untitled" (none) From the called script Regards Peter

 [10/14] from: pwawood:gm:ail at: 28-Dec-2008 13:40


Sunanda
> One possibility is to redefine 'print before the call: > > saved-print: get in system/words 'print > print: func [data][] > ----code here to call other script----- > set in system/words 'print :saved-print
I guess I could just use a my-print function in the called script to re-direct the print from the called script. Though I could re-direct the output with either the /output option or by piping the output in the command. Regards Peter

 [11/14] from: pwawood:gmai:l at: 28-Dec-2008 13:54


Gabriele Thanks. I guess from you suggestion, it isn't easy (or perhaps not even possible) for the called rebol session to have its own terminal session. On 27 Dec 2008, at 19:23, Gabriele Santilli wrote:
> On Sat, Dec 27, 2008 at 6:36 AM, Peter W A Wood <pwawood-gmail.com> > wrote:
<<quoted lines omitted: 3>>
> call "/Applications/Rebol/rebol -qws called.r >/dev/null </dev/ > null"
I'm testing on OS X, the live system is on Windows.
> If the script output is of any importance, you'll want to redirect it > to a log file instead, eg. > > call "/Applications/Rebol/rebol -qws called.r >>> /path/to/logfile.txt </dev/null"
It is useful to see the output during testing. It looks as though re- directing the output will be the best option. For compatibility, it would seem best to use the /output refinement. I tried the /output refinement with an "out" argument of #[none] which I though would be the equivalent of ">/dev/null" but it had no effect. Is this the expected behaviour? Regards Peter When I tried the

 [12/14] from: pwawood:gma:il at: 28-Dec-2008 13:54


Andreas On 28 Dec 2008, at 07:29, Andreas Bolka wrote:
> Have a look at call/output.
Thanks Peter

 [13/14] from: santilli:gabriele:g:mail at: 28-Dec-2008 11:31


On Sun, Dec 28, 2008 at 6:54 AM, Peter W A Wood <pwawood-gmail.com> wrote:
> It is useful to see the output during testing. It looks as though re- > directing the output will be the best option. For compatibility, it > would seem best to use the /output refinement.
Unfortunately, no. /OUTPUT implies /WAIT which is what you wanted to avoid. Maybe you could just connect to a debug script via TCP and send messages there. Regards, Gabriele.

 [14/14] from: pwawood:gmai:l at: 29-Dec-2008 7:40


2008/12/28 Gabriele Santilli <santilli.gabriele-gmail.com>
> On Sun, Dec 28, 2008 at 6:54 AM, Peter W A Wood <pwawood-gmail.com> wrote: > > > It is useful to see the output during testing. It looks as though re- > > directing the output will be the best option. For compatibility, it > > would seem best to use the /output refinement. > > Unfortunately, no. /OUTPUT implies /WAIT which is what you wanted to avoid. >
Thanks Gabriele. I didn't know that. Regards Peter

Notes
  • Quoted lines have been omitted from some messages.
    View the message alone to see the lines that have been omitted