Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

not able to use spawn telnet

Status
Not open for further replies.

yuammy

Technical User
Jul 13, 2011
4
US
Hi,

I'm trying to use TCL to write some scripts to do automation on our test equipment by telnet. But I keep having problem on telnet. Not sure if it's because the compatibility issue since the PC we're using is still Windows 98.

The TCL version installed in PC is 8.0.5

My 1st attempt is to install expect 5.21. ( expect-5.21r1b1-setup.exe)
But after I tried spawn telnet, i got "c:\program files\expect-5.21\bin\slavedrv.exe did not connect to server pipe: No error.

Why???

My 2nd attempt is to install activetcl, I've tried version 8.4.15, 8.4.19, and 8.5.10, they all got the same results that c:\Windows\telnet.exe is not a Win32 console application.

I thought it might be windows98's telnet application issue. So I downloaded win32 telnet console application online. and tried
% spawn c:/telnet/telnet.exe 10.10.10.3
but I got "expect: spawn ip exp2 not open"

Can someone tell what should I do to make telnet work? I'm kinda exhausting on trying all the approaches.

Thank you!
 
Thank you. Right now I was able to use Poor Man's Expect to do telnet. But I wasn't able to telnet it twice such as

proc getinfo {host} {
set output [open test.txt w]
set dataresult [list "gin:" "admin\r\n" "word:" "admin\r\n" ">" "getinfo\r\n" ">" "exit\r\n"]

set final [vexpect [list $host 23] $dataresult]
puts $output "$final"
close $output

}

proc sleep {N} {
after [expr {int($N * 1000)}]
}

puts "1st"
getinfo $host
sleep {10}
puts "2nd"
getinfo $host
puts "finished"


But i can only got the 1st results as
1st
~info~
2nd
finished

Please kindly let me know where I did it wrong. Thank you!

 
Is it possible that you're overwriting test.txt with the same information?

_________________
Bob Rashkin
 
hmm... but I checked test.txt which was empty or timeout waiting on gin.

If i'm overwriting it, there should be something right?

Thank you!
 
So it doesn't write it the first time either? How do you know it runs once?

_________________
Bob Rashkin
 
Also, if the value of "host" doesn't change, you may not be waiting long enough to close the connection.

_________________
Bob Rashkin
 
Cuz the file is empty so I think it only ran once.

However, now it's working if I removed "exit" command.

So now it is like
set dataresult [list "gin:" "admin\r\n" "word:" "admin\r\n" ">" "getinfo\r\n"]

so the telnet session won't be terminated by command but timeout. I also reduce the timeout value in the telnet.tcl so there's not much waiting time.

However, thanks Bob that working this out with me. =)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top