Sponsored Content
Top Forums Shell Programming and Scripting Webpage to Telnet via Perl and Expect: Telnet problem? Post 302217084 by jondo on Tuesday 22nd of July 2008 12:35:09 AM
Old 07-22-2008
(don't mind me...just talking to myself here...)
Fixed problem with finicky Telnet device.
Used Net::Telnet instead of Expect.
When webpage spawned CGI script, this time the Telnet session from Net::Telnet did not send back a NAWS packet to the server,(like Expect did) so the login proceeded normally.
 

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
Net::CLI::Interact(3pm) 				User Contributed Perl Documentation				   Net::CLI::Interact(3pm)

NAME
Net::CLI::Interact - Toolkit for CLI Automation VERSION
version 1.121640 PURPOSE
This module exists to support developers of applications and libraries which must interact with a command line interface. SYNOPSIS
use Net::CLI::Interact; my $s = Net::CLI::Interact->new({ personality => 'cisco', transport => 'Telnet', connect_options => { host => '192.0.2.1' }, }); # respond to a usename/password prompt $s->macro('to_user_exec', { params => ['my_username', 'my_password'], }); my $interfaces = $s->cmd('show ip interfaces brief'); $s->macro('to_priv_exec', { params => ['my_password'], }); # matched prompt is updated automatically # paged output is slurped into one response $s->macro('show_run'); my $config = $s->last_response; DESCRIPTION
Automating command line interface (CLI) interactions is not a new idea, but can be tricky to implement. This module aims to provide a simple and manageable interface to CLI interactions, supporting: o SSH, Telnet and Serial-Line connections o Unix and Windows support o Reuseable device command phrasebooks If you're a new user, please read the Tutorial. There's also a Cookbook and a Phrasebook Listing. For a more complete worked example check out the Net::Appliance::Session distribution, for which this module was written. INTERFACE
new( \%options ) Prepares a new session for you, but will not connect to any device. On Windows platforms, you must download the "plink.exe" program, and pass its location to the "app" parameter. Other options are: "personality => $name" (required) The family of device command phrasebooks to load. There is a built-in library within this module, or you can provide a search path to other libraries. See Net::CLI::Interact::Manual::Phrasebook for further details. "transport => $backend" (required) The name of the transport backend used for the session, which may be one of Telnet, SSH, or Serial. "connect_options => \%options" If the transport backend can take any options (for example the target hostname), then pass those options in this value as a hash ref. See the respective manual pages for each transport backend for further details. "log_at => $log_level" To make using the "logger" somewhat easier, you can pass this argument the name of a log level (such as "debug", "info", etc) and all logging in the library will be enabled at that level. Use "debug" to learn about how the library is working internally. See Net::CLI::Interact::Logger for a list of the valid level names. cmd( $command ) Execute a single command statement on the connected device, and consume output until there is a match with the current prompt. The statement is executed verbatim on the device, with a newline appended. In scalar context the "last_response" is returned (see below). In list context the gathered response is returned as a list of lines. In both cases your local platform's newline character will end all lines. macro( $name, \%options? ) Execute the commands contained within the named Macro, which must be loaded from a Phrasebook. Options to control the output, including variables for substitution into the Macro, are passed in the %options hash reference. In scalar context the "last_response" is returned (see below). In list context the gathered response is returned as a list of lines. In both cases your local platform's newline character will end all lines. last_response Returns the gathered output after the most recent "cmd" or "macro". In scalar context all data is returned. In list context the gathered response is returned as a list of lines. In both cases your local platform's newline character will end all lines. transport Returns the Transport backend which was loaded based on the "transport" option to "new". See the Telnet, SSH, or Serial documentation for further details. phrasebook Returns the Phrasebook object which was loaded based on the "personality" option given to "new". See Net::CLI::Interact::Phrasebook for further details. set_phrasebook( \%options ) Allows you to (re-)configure the loaded phrasebook, perhaps changing the personality or library, or other properties. The %options Hash ref should be any parameters from the Phrasebook module, but at a minimum must include a "personality". set_default_contination( $macro_name ) Briefly, a Continuation handles the slurping of paged output from commands. See the Net::CLI::Interact::Phrasebook documentation for further details. Pass in the name of a defined Contination (Macro) to enable paging handling as a default for all sent commands. This is an alternative to describing the Continuation format in each Macro. To unset the default Continuation, call the "clear_default_continuation" method. logger This is the application's Logger object. A powerful logging subsystem is available to your application, built upon the Log::Dispatch distribution. You can enable logging of this module's processes at various levels, or add your own logging statements. set_global_log_at( $level ) To make using the "logger" somewhat easier, you can pass this method the name of a log level (such as "debug", "info", etc) and all logging in the library will be enabled at that level. Use "debug" to learn about how the library is working internally. See Net::CLI::Interact::Logger for a list of the valid level names. FUTHER READING
Prompt Matching Whenever a command statement is issued, output is slurped until a matching prompt is seen in that output. Control of the Prompts is shared between the definitions in Net::CLI::Interact::Phrasebook dictionaries, and methods of the Net::CLI::Interact::Role::Prompt core component. See that module's documentation for further details. Actions and ActionSets All commands and macros are composed from their phrasebook definitions into Actions and ActionSets (iterable sequences of Actions). See those modules' documentation for further details, in case you wish to introspect their structures. COMPOSITION
See the following for further interface details: o Net::CLI::Interact::Role::Engine AUTHOR
Oliver Gorwits <oliver@cpan.org> COPYRIGHT AND LICENSE
This software is copyright (c) 2012 by Oliver Gorwits. This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. perl v5.14.2 2012-06-12 Net::CLI::Interact(3pm)
All times are GMT -4. The time now is 02:22 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy