Page 1 of 1

(process "telnet")

Posted: Sun Jun 21, 2009 5:00 pm
by nallen05
hi

I am trying to script some tests for a network card with newLISP on Windows XP

When I execute

Code: Select all

(process "telnet")
the telnet application hijacks my cmd prompt (so I can't interact with newlisp until I close telnet) and no input/output from newlisp makes it to/from the telnet process.

Is there a way to control telnet from newLISP with `process'?

Thanks for your time

Nick

Posted: Sun Jun 21, 2009 9:52 pm
by cormullion
I'm not a windows user, but the manual suggests to me that it might be difficult without using peek.

Code: Select all

(map set '(myin telnetout) (pipe))
(map set '(telnetin myout) (pipe))   

(set 'p (process "/usr/bin/telnet" telnetin telnetout))

(define (telnet s)
   (write-buffer myout (string s "\n"))  
   (do-while (!= (peek myin) 0)
       (println "; " (read-line myin))))

(telnet "status")

; telnet> No connection.
; Escape character is '^]'.

(telnet "open 192.168.0.7")

; telnet: connect to address 192.168.0.7: Connection refused
; telnet: Unable to connect to remote host

(destroy p)
which at least looks vaguely promising - the peek helps to get the multiple output lines. But I noticed that the response "Trying 192.168.0.7..." normally seen in the interactive command wasn't collected.

The manual says "Not all interactive console applications can have their standard I/O channels remapped." This might be the case here...

hth

peek / netcat

Posted: Sun Jun 21, 2009 10:36 pm
by nallen05
hey cormullion

thanks for the quick response :-)

unfortuanatly there is no peek on windows!

my guess is an oddity in the behavior of telnet.exe itself, since people seem to be having trouble scripting it with other languages/tools:

http://www.pcreview.co.uk/forums/thread-1904438.php

I downloaded netcat for windows and (process "nc -t <ip> <port>" ncin ncout) seems to be doing the trick. Now I just have to figure out how to filter out all the goat vomit ;-)

thanks again

Nick

Posted: Mon Jun 22, 2009 5:50 pm
by TedWalther
In the Code Patterns document, there should be something about "pipes" You should be using pipes for this.

Ted

Posted: Thu Jun 25, 2009 4:08 pm
by nallen05
"STD I/O pipes" or "scripts as pipes"? STD I/O pipes don't seem to work with any telnet application I can find for Windows.

FWIW I moved on to NET-CONNECT/NET-PEEK/NET-RECEIVE/NET-SEND and am having good results directly reading and writing bytes to the telnet server from newlisp...