Page 1 of 1

request "-p" option

Posted: Tue Oct 05, 2004 5:12 pm
by 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.

Posted: Tue Oct 05, 2004 5:48 pm
by Lutz
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

Posted: Tue Oct 05, 2004 5:58 pm
by newdep
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

Posted: Tue Oct 05, 2004 7:03 pm
by newdep
Geeeeee 8.2.1 is out ;-) 'share should be able to do the trick ;-)

Posted: Tue Oct 05, 2004 7:04 pm
by Lutz
you can also try this in script.lsp:

Code: Select all

(while (read-line) 
	(println (first (net-peer (first (net-sessions)))) ":" (upper-case (current-line))))
it will show the ip# of the peer

lutz