request "-p" option

Q&A's, tips, howto's
Locked
newdep
Posts: 2038
Joined: Mon Feb 23, 2004 7:40 pm
Location: Netherlands

request "-p" option

Post 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.
-- (define? (Cornflakes))

Lutz
Posts: 5289
Joined: Thu Sep 26, 2002 4:45 pm
Location: Pasadena, California
Contact:

Post 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

newdep
Posts: 2038
Joined: Mon Feb 23, 2004 7:40 pm
Location: Netherlands

Post 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
-- (define? (Cornflakes))

newdep
Posts: 2038
Joined: Mon Feb 23, 2004 7:40 pm
Location: Netherlands

Post by newdep »

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

Lutz
Posts: 5289
Joined: Thu Sep 26, 2002 4:45 pm
Location: Pasadena, California
Contact:

Post 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

Locked