[shell core] Shell access for rebol/core on win32
[1/8] from: luke:marmaladefoo at: 10-Jan-2004 14:14
Dear list
I've been annoyed at the lack of shell access in REBOL for
some time now. So I have implemented a simple fix. I
know others have done other fixes, but this works for me.
This setup is for Windows, for unix you would have to
write a slightly different cgi page.
It requires a cgi-compatible webserver (e.g. Apache,
Xitami etc) and python with the python win32 extensions.
python: http://www.python.org/
python win32 extensions:
http://starship.python.net/crew/mhammond/win32/Downloads.html
My contribution are the two scripts below. One REBOL
script which sends the command to the python cgi script
running on a webserver on the same machine. I use Xitami
because it is small and easy to configure, but if you are
running Apache, that should work too.
It uses base64 encoding of the command-line and
response to ensure correct transfer of data without
corruption.
It could be tightened up to increase security (e.g. only
permit connections from 127.0.0.1), but that is left as an
exercise for the reader.
Enjoy!
- Luke
_____REBOL SHELL CLIENT___________
;---the function "call"
;---relies on a python CGI-script which takes one argument "cmd" (base64 encoded command)
;---and returns the result base64 encoded.
;---you will have to set shell-server-url as appropriate
shell-call: func [shell-string /local rslt shell-server-url] [
shell-server-url: http://localhost/cgi-bin/python/execute-cmd.py
rslt: read to-url rejoin [shell-server-url "?cmd=" enbase/base shell-string 64]
return to-string (debase/base :rslt 64)
]
_____PYTHON CGI SHELL SERVER____________
#!/c:\python22\bin\python.exe
import cgi
import win32pipe
import base64
print "Content-Type: text/plain\n\n"
#assume cmd is base64 encoded
cmd = base64.decodestring(The_Form["cmd"].value)
#open a pipe with that command
f = win32pipe.popen(cmd)
#return the response base64 encoded
print base64.encodestring(f.read())
#close the pipe
f.close()
__________________________________________
Various gadgets widgets, links and chat
http://www.marmaladefoo.com
__________________________________________<
[2/8] from: luke:marmaladefoo at: 10-Jan-2004 15:05
Oops I spotted a mistake in my last post, python script
should be as follows. I've reincluded the rebol client too.
The script got broken when I tried to tidy it up too much...
- Luke
________PYTHON CGI SHELL SERVER SCRIPT_______
#!/c:\python22\bin\python.exe
import cgi
import win32pipe
import base64
print "Content-Type: text/plain\n\n"
#get the cgi form data
form = cgi.FieldStorage()
#assume cmd is base64 encoded
base64cmd = form["cmd"].value
cmd = base64.decodestring(base64cmd)
#open a pipe with that command
f = win32pipe.popen(cmd)
#return the response base64 encoded
print base64.encodestring(f.read())
#close the pipe
f.close()
_______END PYTHON SCRIPT___________
_______REBOL SHELL CLIENT_________
;---the function "call"
;---relies on a python CGI-script which takes one argument "cmd" (base64 encoded command)
;---and returns the result base64 encoded.
;---you will have to set shell-server-url as appropriate
shell-call: func [shell-string /local rslt shell-server-url] [
shell-server-url: http://localhost/cgi-bin/python/execute-cmd.py
rslt: read to-url rejoin [shell-server-url "?cmd=" enbase/base shell-string 64]
return to-string (debase/base :rslt 64)
]
____END REBOL SHELL CLIENT FUNCTION__
From: "Luke" <[luke--marmaladefoo--com]>
To: [rebol-list--rebol--com]
Date sent: Sat, 10 Jan 2004 14:14:34 -0000
Subject: [REBOL] [shell core] Shell access for rebol/core on win32
Priority: normal
Send reply to: [rebol-list--rebol--com]
> Dear list
> I've been annoyed at the lack of shell access in REBOL for
<<quoted lines omitted: 51>>
> To unsubscribe from this list, just send an email to
> [rebol-request--rebol--com] with unsubscribe as the subject.
__________________________________________
Various gadgets widgets, links and chat
http://www.marmaladefoo.com
__________________________________________<
[3/8] from: petr:krenzelok:trz:cz at: 10-Jan-2004 16:31
Luke wrote:
>Oops I spotted a mistake in my last post, python script
>should be as follows. I've reincluded the rebol client too.
>
>The script got broken when I tried to tidy it up too much...
>
Hi Luke - what about to wait a bit for 1.3, which will have free shell
access? :-)
-pekr-
[4/8] from: luke:marmaladefoo at: 10-Jan-2004 16:38
Hi Petr
Is that the new REBOL/View. Will REBOL/Core have it too?
Is there a list anywhere of what the new features will be?
As for waiting - I've done enough of that ;-)
- Luke
> >
> Hi Luke - what about to wait a bit for 1.3, which will have free shell
<<quoted lines omitted: 7>>
> To unsubscribe from this list, just send an email to
> [rebol-request--rebol--com] with unsubscribe as the subject.
__________________________________________
Various gadgets widgets, links and chat
http://www.marmaladefoo.com
__________________________________________<
[5/8] from: greggirwin::mindspring::com at: 10-Jan-2004 10:09
Hi Luke,
Very clever! Another example of thinking outside the interpreter.
-- Gregg
[6/8] from: petr:krenzelok:trz:cz at: 10-Jan-2004 18:27
Luke wrote:
>Hi Petr
>
>Is that the new REBOL/View. Will REBOL/Core have it too?
>
>Is there a list anywhere of what the new features will be?
>
>As for waiting - I've done enough of that ;-)
>
It seems like you are ignoring completly real and ongoing View 1.3
project, where anybody from rebol community is invited to participate? ;-)
http://www.rebol.net/projects/view1.3/indexd.html
btw - even when RT did not plan to do some larger changes, there is now
completly new implementation of image datatype.
http://www.rebol.net/projects/view1.3/image.html
lot's of bug fixed, lots of issues reported -
http://www.rebol.net/cgi-bin/projects/track.r
you can download experimental releases here -
http://www.rebol.net/projects/view1.3/downloads/
So, what - is that effort real or not? :-)
-pekr-
[7/8] from: jason:cunliffe:verizon at: 10-Jan-2004 13:09
/View 1.3 seems like a very good joint effort..
Q1: Good news about Shell Access. Does that mean there will soon be a free
rebol with shell access, or only via some purchased version? If so what
price?
Q3: Where are the docs?
I only see http://www.rebol.net/projects/view1.3/rebolview.html but links
are all dead
Q3: Does View 1.3 support clipboard copy of images from the OS?
thanks
- Jason
[8/8] from: petr:krenzelok:trz:cz at: 10-Jan-2004 20:32
Jason Cunliffe wrote:
>/View 1.3 seems like a very good joint effort..
>
>Q1: Good news about Shell Access. Does that mean there will soon be a free
>rebol with shell access, or only via some purchased version? If so what
>price?
>
it will be allowed in free versions imo ....
>Q3: Where are the docs?
>I only see http://www.rebol.net/projects/view1.3/rebolview.html but links
>are all dead
>
yes, links are dead - so far ppl + RT concentrate upon bugfixing,
patching functionality, adding new stuff, there was no time for docs.
Above link just shows the structure proposed by Carl and most ppl agreed
that if chapters are written according to posted scheme, the docs will
be good.
>Q3: Does View 1.3 support clipboard copy of images from the OS?
>
I doubt that ... you can join-in and post it to the tracker as a wish ;-)
-pekr-
Notes
- Quoted lines have been omitted from some messages.
View the message alone to see the lines that have been omitted