Sponsored Content
Special Forums UNIX and Linux Applications Infrastructure Monitoring expect telnet unexpected delays Post 302315601 by kp2a on Tuesday 12th of May 2009 10:35:43 PM
Old 05-12-2009
expect telnet unexpected delays

I must automatically monitor and manage a large number of boxes on our network.

I have been using perl/Net::Telnet and expect/telnet and also perl/ssh and expect/ssh to reach the command line of the remote boxes. Scripts are working but slow.

(Yes, I do use SNMP also but many boxes do not speak SNMP)

I believe that there is some protocol or terminal negotiating that I may be ignoring that blocks when the remote box sends a query and I do not respond.

I tried to read the RFC on Telnet which appeared to have an infinite number of options. My application is very simple: get to the remote command line.

Here is an example of expect/ssh (telnet exactly the same result) that includes unexpected data then the remote blocks for 10 seconds (local or remote default timeout?) then continues with expected response.
Code:
expect: set expect_out(buffer) "admin@10.100.72.223's password:"
send: sending "xxxxx\r" to { exp4 }
(logo deleted)
  MikroTik RouterOS 3.20 (c) 1999-2009       http://www.mikrotik.com/

  ^[[?62;9;c^[[39;3Rexpect: timed out

expect: does " \r\n\r\r\n\r\r\n\r\r\n\r\r\n\r\r\n\r\r\n\r\r\n\r\n\r  MMM      MMM     
(expected data deleted)
   MikroTik RouterOS 3.20 (c) 1999-2009       http://www.mikrotik.com/\r\n\r\r\n\r
\u001b[9999B\r\u001b[9999B\u001bZ  \u001b[6n" (spawn_id exp4) match glob 
pattern " > "? no

You see I was looking for the prompt, " > ", which does appear 10 seconds later!

Part does appear to be a terminal command. I have to guess the remote box is asking me a question and I am failing to answer.

Surprising is that using ssh rather than Telnet gives the same results.
Manual use of ssh or Telnet = no delays.
Script use of ssh or Telnet = 10 second delays for each send/expect cycle!

Can some one give me a clue???
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Unexpected Results (at least I did not expect them)

I have two sripts running in bash. The first one uncompresses log files and moves them to a working directory using uncompress -c and > output to new directory. It then creates one control record to assure our search returns a record. It then calls or executes the second script, which is a grep for... (6 Replies)
Discussion started by: altamaha
6 Replies

2. Shell Programming and Scripting

Webpage to Telnet via Perl and Expect: Telnet problem?

Somewhat long story: I have a simple Perl CGI script that uses Expect to Telnet to a device and grab some data, and then spits it back to Perl for display on the Webpage. This works for many devices I've tried, but one device just fails, it keeps rejecting the password on this device, only... (1 Reply)
Discussion started by: jondo
1 Replies

3. Shell Programming and Scripting

Need 'expect' help, ssh/telnet and trapping

So here is what I am trying to do. I have a large # of switches and routers I am trying to log into. Unfortunately some have ssh only, some have telnet only. and some i have never logged into with ssh. I first want it to SSH, if i have never logged into the box it will ask for adding the ssh key. I... (0 Replies)
Discussion started by: ippy98
0 Replies

4. Shell Programming and Scripting

Telnet Expect script question

Hi all, I have written a small expect script which should spawn a telnet session login and execute some commands. #!/usr/bin/expect -f spawn telnet $env(IP) match_max 100000 expect "login:" send -- "******\n" expect -exact "Password:" send -- "****\n" expect "%" Now I have got... (2 Replies)
Discussion started by: stinkefisch
2 Replies

5. Shell Programming and Scripting

telnet commands using expect

Hi All, I am trying to write a expect script to telnet and run a command on a remote host.The command i want to send contains a text value is contained in file.txt in the linux box from where i am running the expect script.I want to pass the contains of file.txt into a variable and call the... (1 Reply)
Discussion started by: pistachio
1 Replies

6. Shell Programming and Scripting

Help needed with expect...(If telnet fails)

Hello I'm working using expect to automate telnet commands...i want to check if telnet fails and in this case...certain message should appear or certain word should be out in a file). Thses are the messages that apeear if telnet fails: Trying 172.16.3.115... telnet: Unable to connect... (0 Replies)
Discussion started by: Hossam_Nox
0 Replies

7. Shell Programming and Scripting

expect: redirect telnet to file

I've got some expect/tcl scripts. Now i want to add a function that allows to open a telnet connection and redirect the output to a logfile. On the shell/terminal i tried something like: 'telnet 192.168.123.123 12121 > /home/user/logging/log-telnet.log' and the telnet is redirected into the... (2 Replies)
Discussion started by: JaPatton
2 Replies

8. Shell Programming and Scripting

Expect/telnet/testing tacacs on a cisco

At times I find the need to test that the tacacs port 49 is open. The code below works but is painfully slow because I have to wait on the timeouts. Examples of possible responds router1#telnet 10.11.20.14 49 Trying 206.112.204.140, 49 ... Open route1#telnet 10.11.19.14 49 Trying... (1 Reply)
Discussion started by: popeye
1 Replies

9. Shell Programming and Scripting

Calling Expect Script - Telnet

Hi All, I have an Expect script which logs into Cisco switch, performs a show interface command. I want to read a file of ip addresses which will be passed to the expect script. The script to read the file works, the expect script works on it's own but when i call the 'expect' script from the... (12 Replies)
Discussion started by: trinak96
12 Replies

10. Shell Programming and Scripting

expect telnet script execute by cronjob

hi, please help, keep getting this bolded error and look it up and people say its your environment variable though i tried to set it manually in expect..it run fine if i run it manually but once i run it by cronjob it error below..i tried to comment out ip/login info with *.. logfile:: START... (0 Replies)
Discussion started by: cssanangeles
0 Replies
set_color(1)							       fish							      set_color(1)

NAME
set_color - set_color - set the terminal color set_color - set the terminal color Synopsis set_color [-v --version] [-h --help] [-b --background COLOR] [COLOR] Description Change the foreground and/or background color of the terminal. COLOR is one of black, red, green, brown, yellow, blue, magenta, purple, cyan, white and normal. o -b, --background Set the background color o -c, --print-colors Prints a list of all valid color names o -h, --help Display help message and exit o -o, --bold Set bold or extra bright mode o -u, --underline Set underlined mode o -v, --version Display version and exit Calling set_color normal will set the terminal color to whatever is the default color of the terminal. Some terminals use the --bold escape sequence to switch to a brighter color set. On such terminals, set_color white will result in a grey font color, while set_color --bold white will result in a white font color. Not all terminal emulators support all these features. This is not a bug in set_color but a missing feature in the terminal emulator. set_color uses the terminfo database to look up how to change terminal colors on whatever terminal is in use. Some systems have old and incomplete terminfo databases, and may lack color information for terminals that support it. Download and install the latest version of ncurses and recompile fish against it in order to fix this issue. Version 1.23.1 Sun Jan 8 2012 set_color(1)
All times are GMT -4. The time now is 04:22 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy