request "-p" option

Started by newdep, October 05, 2004, 10:12:35 AM

Previous topic - Next topic

newdep

Hello Lutz,



This might sound strange but im missing something ;-)



Actualy the newlisp script.lsp -p 9090 is a great option but not interacting

with the session at 9090. So I thought perhpas its possible to enhance the

"-p" option with a script to be executed "after" the sessions is set-up instead of befor the sessions is activated ?



Regards, Norman.
-- (define? (Cornflakes))

Lutz

#1
After the session is activated newLISP waits for input on the port specified, so there is no way to execute while sitting in a fgets() function, it has to process script.lsp before waiting for input.



Perhaps things work like you want it, putting script.lsp after the -p option:



newlisp -p 22222 script.lsp



In this mode newlisp will (1) set up the port and listen (2) load the script (3) and now wait for input and process it.



The -p option replaces all stdio to go over a network socket, newLISP itself 'thinks' it is just in normal interactive console mode.



What 'script.lsp' could do is set up a program using (read-line) and (print ...), (println ..), (write-line ..) all 4 functions would automatically work on the port specified. Put this into script.lsp:



(while (read-line) (write-line (upper-case (current-line))))



Now do a:



telnet localhost 22222



You will see the sign-on banner and then you can enter a string of characters which will be echoed back to you in uppercase.





Lutz

newdep

#2
Thanks Lutz..



Im trying to establish an "Access-List" to reduce ip access

when Newlisp is in "-p" mode and thought it worked using a newlisp script,

but no result even not when i turn around the script on the command-line.



Perhpas its an enhancment option for in init.lsp ?



Regards. Norman
-- (define? (Cornflakes))

newdep

#3
Geeeeee 8.2.1 is out ;-) 'share should be able to do the trick ;-)
-- (define? (Cornflakes))

Lutz

#4
you can also try this in script.lsp:

(while (read-line)
(println (first (net-peer (first (net-sessions)))) ":" (upper-case (current-line))))


it will show the ip# of the peer



lutz