(process "telnet")

Machine-specific discussion
Unix, Linux, OS X, OS/2, Windows, ..?
Locked
nallen05
Posts: 21
Joined: Sun Apr 19, 2009 10:12 pm

(process "telnet")

Post 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

cormullion
Posts: 2038
Joined: Tue Nov 29, 2005 8:28 pm
Location: latiitude 50N longitude 3W
Contact:

Post 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

nallen05
Posts: 21
Joined: Sun Apr 19, 2009 10:12 pm

peek / netcat

Post 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

TedWalther
Posts: 608
Joined: Mon Feb 05, 2007 1:04 am
Location: Abbotsford, BC
Contact:

Post by TedWalther »

In the Code Patterns document, there should be something about "pipes" You should be using pipes for this.

Ted

nallen05
Posts: 21
Joined: Sun Apr 19, 2009 10:12 pm

Post 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...

Locked