Sponsored Content
Top Forums Shell Programming and Scripting Webpage to Telnet via Perl and Expect: Telnet problem? Post 302216695 by jondo on Monday 21st of July 2008 01:12:47 AM
Old 07-21-2008
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 accepts one character.
I have sniffed out the traffic and the interaction seems to be valid.
The only clue i think i found is the Telnet negotiation, which I discovered from the telnet debug code:

But when it is spawned by the webpage, there is a difference in this line of code Telnet debug code:
SENT IAC SB NAWS 0 0 (0) 0 0 (0)

The CGI script runs fine when launched from the shell, and shows this code:
SENT IAC SB NAWS 0 80 (80) 0 24 (24)

So...I have given up on everything else, all I can think is that the device, possibly poorly coded and non-compliant, is crapping out on the Web server environment with 0 0 for columns and lines.
If this is the issue, does anyone know a way to force Telnet into standard 80x24 mode, or ignore the negotiation?
This equipment is discontinued and cannot go back to manufacturer to fix their Telnet code.

Thanks
JD
 

10 More Discussions You Might Find Interesting

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

2. Infrastructure Monitoring

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... (2 Replies)
Discussion started by: kp2a
2 Replies

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

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

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

6. Shell Programming and Scripting

Expect script to automate telnet session

Hi all, I am currently running a daemon which creates a virtual terminal for testing purposes. Essentially, if I were to interact with it manually, this is what I get. john@test1:~$telnet localhost 7777 Trying ::1... Connected to localhost. Escape character is '^]' mip6d> pl eth2... (6 Replies)
Discussion started by: abxccd
6 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
TELNETD(8)						    BSD System Manager's Manual 						TELNETD(8)

NAME
telnetd -- DARPA TELNET protocol server SYNOPSIS
/usr/libexec/telnetd [-46BUhlkn] [-D debugmode] [-S tos] [-X authtype] [-a authmode] [-edebug] [-p loginprog] [-u len] [-debug [port]] DESCRIPTION
The telnetd command is a server which supports the DARPA standard TELNET virtual terminal protocol. Telnetd is normally invoked by the internet server (see inetd(8)) for requests to connect to the TELNET port as indicated by the /etc/services file (see services(5)). The -debug option may be used to start up telnetd manually, instead of through inetd(8). If started up this way, port may be specified to run telnetd on an alternate TCP port number. The telnetd command accepts the following options: -4 Forces telnetd to use IPv4 addresses only. -6 Forces telnetd to use IPv6 addresses only. -a authmode This option may be used for specifying what mode should be used for authentication. Note that this option is only useful if telnetd has been compiled with support for the AUTHENTICATION option. There are several valid values for authmode: debug Turn on authentication debugging code. user Only allow connections when the remote user can provide valid authentication information to identify the remote user, and is allowed access to the specified account without providing a password. valid Only allow connections when the remote user can provide valid authentication information to identify the remote user. The login(1) command will provide any additional user verification needed if the remote user is not allowed automatic access to the specified account. other Only allow connections that supply some authentication information. This option is currently not supported by any of the existing authentication mechanisms, and is thus the same as specifying -a valid. none This is the default state. Authentication information is not required. If no or insufficient authentication information is provided, then the login(1) program will provide the necessary user verification. off Disable the authentication code. All user verification will happen through the login(1) program. -B Specify bftp server mode. In this mode, telnetd causes login to start a bftp(1) session rather than the user's normal shell. In bftp daemon mode normal logins are not supported, and it must be used on a port other than the normal TELNET port. -D debugmode This option may be used for debugging purposes. This allows telnetd to print out debugging information to the connection, allowing the user to see what telnetd is doing. There are several possible values for debugmode: options Print information about the negotiation of TELNET options. report Print the options information, plus some additional information about what processing is going on. netdata Display the data stream received by telnetd. ptydata Display data written to the pty. exercise Has not been implemented yet. -debug Enable debugging on each socket created by telnetd (see SO_DEBUG in socket(2)). -edebug If telnetd has been compiled with support for data encryption, then the -edebug option may be used to enable encryption debugging code. -h Disable the printing of host-specific information before login has been completed. -k This option is only useful if telnetd has been compiled with both linemode and kludge linemode support. If the -k option is speci- fied, then if the remote client does not support the LINEMODE option, then telnetd will operate in character at a time mode. It will still support kludge linemode, but will only go into kludge linemode if the remote client requests it. (This is done by the client sending DONT SUPPRESS-GO-AHEAD and DONT ECHO.) The -k option is most useful when there are remote clients that do not support kludge linemode, but pass the heuristic (if they respond with WILL TIMING-MARK in response to a DO TIMING-MARK) for kludge linemode support. -l Specify line mode. Try to force clients to use line-at-a-time mode. If the LINEMODE option is not supported, it will go into kludge linemode. -n Disable TCP keep-alives. Normally telnetd enables the TCP keep-alive mechanism to probe connections that have been idle for some period of time to determine if the client is still there, so that idle connections from machines that have crashed or can no longer be reached may be cleaned up. -p loginprog Specify an alternate login(1) command to run to complete the login. The alternate command must understand the same command arguments as the standard login. -S tos Sets the IP type-of-service (TOS) option for the telnet connection to the value tos, which can be a numeric TOS value or, on systems that support it, a symbolic TOS name found in the /etc/iptos file. -u len This option is used to specify the size of the field in the utmp structure that holds the remote host name. If the resolved host name is longer than len, the dotted decimal value will be used instead. This allows hosts with very long host names that overflow this field to still be uniquely identified. Specifying -u0 indicates that only dotted decimal addresses should be put into the utmp file. -U This option causes telnetd to refuse connections from addresses that cannot be mapped back into a symbolic name via the gethostbyaddr(3) routine. -X authtype This option is only valid if telnetd has been built with support for the authentication option. It disables the use of authtype authentication, and can be used to temporarily disable a specific authentication type without having to recompile telnetd. Available authtype values include KERBEROS_V4, KERBEROS_V5, SPX, MINK, and SRA. These options are completely independent of the -a option. Telnetd operates by allocating a pseudo-terminal device (see pty(4)) for a client, then creating a login process which has the slave side of the pseudo-terminal as stdin, stdout and stderr. Telnetd manipulates the master side of the pseudo-terminal, implementing the TELNET proto- col and passing characters between the remote client and the login process. When a TELNET session is started up, telnetd sends TELNET options to the client side indicating a willingness to do the following TELNET options, which are described in more detail below: DO AUTHENTICATION WILL ENCRYPT DO TERMINAL TYPE DO TSPEED DO XDISPLOC DO NEW-ENVIRON DO ENVIRON WILL SUPPRESS GO AHEAD DO ECHO DO LINEMODE DO NAWS WILL STATUS DO LFLOW DO TIMING-MARK The pseudo-terminal allocated to the client is configured to operate in ``cooked'' mode, and with XTABS and CRMOD enabled (see tty(4)). Telnetd has support for enabling locally the following TELNET options: WILL ECHO When the LINEMODE option is enabled, a WILL ECHO or WONT ECHO will be sent to the client to indicate the current state of terminal echoing. When terminal echo is not desired, a WILL ECHO is sent to indicate that telnetd will take care of echo- ing any data that needs to be echoed to the terminal, and then nothing is echoed. When terminal echo is desired, a WONT ECHO is sent to indicate that telnetd will not be doing any terminal echoing, so the client should do any terminal echoing that is needed. WILL BINARY Indicate that the client is willing to send a 8 bits of data, rather than the normal 7 bits of the Network Virtual Termi- nal. WILL SGA Indicate that it will not be sending IAC GA, go ahead, commands. WILL STATUS Indicate a willingness to send the client, upon request, of the current status of all TELNET options. WILL TIMING-MARK Whenever a DO TIMING-MARK command is received, it is always responded to with a WILL TIMING-MARK. WILL LOGOUT When a DO LOGOUT is received, a WILL LOGOUT is sent in response, and the TELNET session is shut down. WILL ENCRYPT Only sent if telnetd is compiled with support for data encryption, and indicates a willingness to decrypt the data stream. Telnetd has support for enabling remotely the following TELNET options: DO BINARY Sent to indicate that telnetd is willing to receive an 8 bit data stream. DO LFLOW Requests that the client handle flow control characters remotely. DO ECHO This is not really supported, but is sent to identify a 4.2BSD telnet(1) client, which will improperly respond with WILL ECHO. If a WILL ECHO is received, a DONT ECHO will be sent in response. DO TERMINAL-TYPE Indicate a desire to be able to request the name of the type of terminal that is attached to the client side of the con- nection. DO SGA Indicate that it does not need to receive IAC GA, the go ahead command. DO NAWS Requests that the client inform the server when the window (display) size changes. DO TERMINAL-SPEED Indicate a desire to be able to request information about the speed of the serial line to which the client is attached. DO XDISPLOC Indicate a desire to be able to request the name of the X Window System display that is associated with the telnet client. DO NEW-ENVIRON Indicate a desire to be able to request environment variable information, as described in RFC 1572. DO ENVIRON Indicate a desire to be able to request environment variable information, as described in RFC 1408. DO LINEMODE Only sent if telnetd is compiled with support for linemode, and requests that the client do line by line processing. DO TIMING-MARK Only sent if telnetd is compiled with support for both linemode and kludge linemode, and the client responded with WONT LINEMODE. If the client responds with WILL TM, the it is assumed that the client supports kludge linemode. Note that the [-k] option can be used to disable this. DO AUTHENTICATION Only sent if telnetd is compiled with support for authentication, and indicates a willingness to receive authentication information for automatic login. DO ENCRYPT Only sent if telnetd is compiled with support for data encryption, and indicates a willingness to decrypt the data stream. NOTES
By default telnetd will read the he, hn, and im capabilities from /etc/gettytab and use that information (if present) to determine what to display before the login: prompt. You can also use a System V style /etc/issue file by using the if capability, which will override im. The information specified in either im or if will be displayed to both console and remote logins. FILES
/etc/services /etc/gettytab /etc/iptos (if supported) /usr/ucb/bftp (if supported) SEE ALSO
bftp(1), login(1), telnet(1) (if supported), gettytab(5) STANDARDS
RFC-854 TELNET PROTOCOL SPECIFICATION RFC-855 TELNET OPTION SPECIFICATIONS RFC-856 TELNET BINARY TRANSMISSION RFC-857 TELNET ECHO OPTION RFC-858 TELNET SUPPRESS GO AHEAD OPTION RFC-859 TELNET STATUS OPTION RFC-860 TELNET TIMING MARK OPTION RFC-861 TELNET EXTENDED OPTIONS - LIST OPTION RFC-885 TELNET END OF RECORD OPTION RFC-1073 Telnet Window Size Option RFC-1079 Telnet Terminal Speed Option RFC-1091 Telnet Terminal-Type Option RFC-1096 Telnet X Display Location Option RFC-1123 Requirements for Internet Hosts -- Application and Support RFC-1184 Telnet Linemode Option RFC-1372 Telnet Remote Flow Control Option RFC-1416 Telnet Authentication Option RFC-1411 Telnet Authentication: Kerberos Version 4 RFC-1412 Telnet Authentication: SPX RFC-1571 Telnet Environment Option Interoperability Issues RFC-1572 Telnet Environment Option HISTORY
IPv6 support was added by WIDE/KAME project. BUGS
Some TELNET commands are only partially implemented. Because of bugs in the original 4.2BSD telnet(1), telnetd performs some dubious protocol exchanges to try to discover if the remote client is, in fact, a 4.2BSD telnet(1). Binary mode has no common interpretation except between similar operating systems (Unix in this case). The terminal type name received from the remote client is converted to lower case. Telnetd never sends TELNET IAC GA (go ahead) commands. BSD
August 28, 2008 BSD
All times are GMT -4. The time now is 10:14 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy