r3wp [groups: 83 posts: 189283]
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search
 

World: r3wp

[Linux] group for linux REBOL users

Anton
14-Aug-2009
[3054]
Ahh, pity it doesn't seem to work in the rebol shell...
Dockimbel
14-Aug-2009
[3055]
Maybe you could write a simple proxy for system/ports/input, catch 
CTRL-V then redirect clipboard:// content to console?
Izkata
14-Aug-2009
[3056]
Any particular reason middle-click wouldn't work?
Anton
15-Aug-2009
[3057x6]
Doc, yeah I was wondering about system/ports/input...
Izkata, middle-click doesn't access the same clipboard.
Actually, it looks like  read clipboard://  accesses the same clipboard 
as middle-click, which is better than nothing, but still doesn't 
make it perfect...
Wait a minute, I can call xclip to get the right clipboard contents...
	>> call "xclip -o"
That prints the clipboard contents into the rebol shell.
Oops, that should actually be:
	>> call "xclip -o -selection clipboard"
Doc, or anyone, do you know how to write a proxy for system/ports/input 
?
Dockimbel
15-Aug-2009
[3063]
I would try to wrap a custom port wiring all methods to the console 
port then I would replace system/ports/input with that new one and 
see if the "proxy" port works. If it works, then you can intercept 
the incoming events and add your own handlers. But that's only theory, 
as much other low-level parts of REBOL, it's not documented, so I'm 
not sure it would work.
Anton
15-Aug-2009
[3064]
Hmm.. sounds a bit too complicated for now - might have to wait for 
another day...

but, how do you think I would replace system/ports/input ? By just 
:

	system/ports/input: my-port
?
Dockimbel
15-Aug-2009
[3065]
Yes.
Anton
15-Aug-2009
[3066x6]
Ok, I'll give it a quick go to see how feasible it is. My first try 
about an hour and half ago, just using the console port looks like 
this:
console-port: open/binary/no-wait console:/
console-port/awake: func [port /local ch][
	if ch: pick port 1 [
		;print ["Console awake trapped key:" to-char ch "(" ch ")"]
		either ch = #"^V" [	; Ctrl+V

   call "xclip -o -selection clipboard" ; Three different types of clipboards: 
   "primary", "secondary" or "clipboard".
		][
			insert system/ports/output to-char ch
		]
	]
	return false ; Does not cause return from WAIT (DO-EVENTS).
	;true ; Does cause return from WAIT (DO-EVENTS).
]

insert system/ports/wait-list console-port
if error? set/any 'err try [
	do-events
][
	print mold disarm err
]
close console-port
remove find system/ports/wait-list console-port
I've tried replacing system/ports/input/awake with an awake function 
similar to above, and it doesn't seem ever to be called. If it's 
possible at all I think making a handler object with all the functions 
(open close write etc.) *might* work.
I don't really know what I'm doing with ports. I need more information. 
All I can get it to do is shutdown rebol on keypress.
I tried making a handler object with stub functions.
No joy.
Gabriele
17-Aug-2009
[3072x3]
awake is only called if you use WAIT (which the native console does 
not use - indeed you don't get other port events while at the console 
prompt)
i did replace system/ports/input and output and it works, i used 
that to "broadcast" what is typed at the console to other listener 
(eg. for online demos or lessons or things like that).
http://www.colellachiara.com/soft/Misc/broadcast-console.r
Graham
17-Aug-2009
[3075]
Is this a key logger?
Gabriele
17-Aug-2009
[3076]
lol, you can see it this way.
Anton
17-Aug-2009
[3077]
Gabriele, thanks, that's very interesting, I will check it out. (Aha 
 make Root-protocol, I forgot about that.)
Anton
18-Aug-2009
[3078]
I had a go at it again with Gabriele's way of doing it. So far I 
can only intercept input and output when enter is pressed, not at 
individual key presses. I think I can only open system/ports/input 
in lines mode, the same as the default. From memory, now, I seem 
to remember somebody having a go at this and arriving at the same 
point. (Can anybody verify that?)
Pekr
18-Aug-2009
[3079x2]
Not sure I heard anything like that. The only thing I remember is 
that we got some advanced console mode, where you could use any key 
IIRC. There was even some animation done by Bo. The article was at 
rebolforces.com somewhere - not sure it could help your case though 
..
Ah, that is something different than what you need - http://www.rebolforces.com/articles/tui-dialect/
... but it reminded me to remember, how badly the windows console 
sucks :-(
Gabriele
18-Aug-2009
[3081x2]
system/ports/input needs to be in /lines mode IIRC... but you could 
open console:// in /binary mode, process it, and behave in lines 
mode for your custom scheme. More complicated than my example above 
for sure...
(still, ctrl-c and ctrl-v have always had a different meaning on 
terminals, so I'm not sure replacing them is a good idea. in particular, 
most likely you'd need to trap ctrl-c by trapping SIGINT... and that 
does not look like a great idea to me...)
Anton
18-Aug-2009
[3083x2]
Gabriele, could elaborate on that idea a bit? I'm having trouble 
visualizing how it would work.
(You are right about terminal signalling, but of course this is not 
the only thing this proxy port is useful for.)
Gabriele
19-Aug-2009
[3085x2]
in my example, you have your own port using your own scheme, and 
its sub-port which is the original system/ports/input. this sub-port 
need not be the original, you can open console:// yourself with your 
own flags (eg. binary). then you can process one char at a time, 
figure out line ending yourself, and send the entire line to the 
other side.
i think I probably need to write some code to make it more clear...
Anton
19-Aug-2009
[3087]
That makes it much more clear.
Anton
22-Aug-2009
[3088x5]
Hmm... more thinking and lots of questions come up.
Would your above system need WAIT ?

The only way I got console port to work is to set its awake function 
and use WAIT.
Or is there a way to set the handler in a console port?
Anyway, so it seems like you suggest to replace the default port 
at system/ports/input with an equivalent one which the system is 
expecting (ie. a direct/read/lines port), and then the subport can 
be a custom console port with binary, one char at a time stuff.
(It's unclear to me the relationship between a port and its subport. 
I know the port manages the opening/closing of its subport, but how 
can the port in lines mode transfer individual chars from its buffer 
into the subport ? Or do they both receive from the same input simultaneously 
automatically?)
Gabriele
23-Aug-2009
[3093x2]
when you're not in pass-thru mode, the only functions that get called 
are read and write. they both work at the binary level (read-io and 
write-io), so the conversion to lines is done by the native code 
under the hood. i don't know if you need pass-thru, though, and whether 
pass-thru will work for system/ports/input.
basically, on read you call read-io on the subport, maybe modify 
the buffer, etc. on write (for the output port), you can do the same, 
modify the buffer, then use write-io on the subport. wait on the 
subport is called by the system whenever wait on your port is called 
(that's why there's a get-sub-port function there).
Graham
28-Aug-2009
[3095x2]
Anyone know anything Apache exploits?  My site has been defaced http://www.compkarori.co.nz:8090
This was running Mindtouch deki wiki ... but now I get the same rubbish 
at any page so I suspect something is up with Apache.
Oldes
28-Aug-2009
[3097]
you have been Hacked By Cyb3rking
yeksoon
28-Aug-2009
[3098x2]
do u have direct access to the server?
may need to shut off the various ports first before you can even 
get it resolved
Oldes
28-Aug-2009
[3100]
http://tech.yahoo.com/qa/20090328150137AAzlEuc
Graham
28-Aug-2009
[3101x3]
don't understand the yahoo thing
there's only one port open to the world .. the one for web access
well, going to login to the console and have a poke around