Expect with tcl/tk


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Expect with tcl/tk
# 1  
Old 10-10-2005
Expect with tcl/tk

hai all,
i have an tcl script in which i have been reading the DUT Command prompt of an cisco switch as
DUT Command Prompt : cisco*
and running the test case of stp now the problem is if i have given any blank space in between the cisco or at the startup then the Expect is not identifying the DUT command prompt . is there any solution in expect so that if any blank space comes then further process can be carry on not specifying that DUT Command prompt not recognizable

Regards,
Sanju
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Red Hat

Issue in installing expect and Tcl

Hi I need to install expect in redhat. through net I came to know that I must install tcl too in order to make expect work. I have downloaded both packages but not able to install # ls -lrt total 3720 18:33 tcl8.4.20-src.tar.gz 18:33 expect5.45.3.tar.gz 18:40 expect5.45.3... (7 Replies)
Discussion started by: scriptor
7 Replies

2. Shell Programming and Scripting

Convert my shell script into expect/tcl

hi experts, how will i convert the first part of my script into expect or tcl since shell script cannot be embedded into expect script ? i have 100+ servers in my serverlist. how will i call or declare it in expect or tcl ? #!/usr/sbin/expect -f serverlist=`cat $1` for i in serverlist... (2 Replies)
Discussion started by: linuxgeek
2 Replies

3. Shell Programming and Scripting

expect TCL script

Hello, I write a TCL script for Expect/ Telnet. I want to send command to the telnet server. But I want to close after the command is sent. Anybody know which command can flush the expect so I can sure the command is sent to the telnet server??? EX: send "./command1\r" close... (0 Replies)
Discussion started by: linboco
0 Replies

4. UNIX for Dummies Questions & Answers

Expect/Tcl help

hi, I am new in Expect. I have a question about expect timeout. suppose I have a structure of expect { ".."{ send"............"} timeout{ ............... } } The silly question is if I reach timeout, how can I store the error message showing on the screen to... (2 Replies)
Discussion started by: allenxiao7
2 Replies

5. Shell Programming and Scripting

TCL/Expect not working as expected

I am having an issue with TCL\Expect; I am passing arguments via the commandline that are read in via "lrange $argv". One of those var's is a password with characters that need to be escapaed, after escaping them an hitting enter expect is placing curly braces around my password... why?! ... (4 Replies)
Discussion started by: RiSk
4 Replies

6. Shell Programming and Scripting

Help with TCL/Expect in Solaris 5.3

I'm having this problem with a very simple tcl expect script that is running on Solaris 5.3 with TCL version 8.4.7 and expect version 5.0. below is the simplified version of the code snippet, which I think has everything to illustrate the problem, the full version is at the very bottom in... (0 Replies)
Discussion started by: pinchharmonic
0 Replies

7. Shell Programming and Scripting

tcl/expect

Can someone identify what is the problem here?. no children while executing "exp_wait -nowait -i -1" (procedure "logOptions" line 45) invoked from within "logOptions" (procedure "doExecute" line 98) invoked from within "doExecute" (procedure "main" line 32) ... (7 Replies)
Discussion started by: calsum
7 Replies

8. Shell Programming and Scripting

Tcl expect HELP

In the following "for" loop I assume the the script will expect "anyway", "first" NOT in any paticular order and send "yes" when there found, breaking out of the loop when "$prompt" is found. The way it is working is like 3 individual expect lines, and they MUST be in cronological order. ANY help... (0 Replies)
Discussion started by: dave_m
0 Replies

9. UNIX for Dummies Questions & Answers

Expect/Tcl help?

Does anyone know of an expect/tcl forum that is as helpful as this one is for shell scripting? Or if anyone has any expect knowledge, can you please provide some guidance on how to write to a local error log based on output from a ssh session? I have something like this: foreach host... (2 Replies)
Discussion started by: earnstaf
2 Replies

10. Shell Programming and Scripting

TCL/Expect project questions

I am rewriting the first big script project I ever coded to clean up some issues, mainly my really clumsy bash code, and to migrate to TCL/Expect. I have a couple of questions that I could use some help with. 1.) The script needs to know where it is located. I realize that I could use "find /... (1 Reply)
Discussion started by: thumper
1 Replies
Login or Register to Ask a Question
Expect::Simple(3pm)					User Contributed Perl Documentation				       Expect::Simple(3pm)

NAME
Expect::Simple - wrapper around the Expect module SYNOPSIS
use Expect::Simple; my $obj = new Expect::Simple { Cmd => [ dmcoords => 'verbose=1', "infile=$infile"], Prompt => [ -re => 'dmcoords>:s+' ], DisconnectCmd => 'q', Verbose => 0, Debug => 0, Timeout => 100 }; $obj->send( $cmd ); print $obj->before; print $obj->after; print $obj->match_str, " "; print $obj->match_idx, " "; print $obj->error_expect; print $obj->error; $expect_object = $obj->expect_handle; DESCRIPTION
"Expect::Simple" is a wrapper around the "Expect" module which should suffice for simple applications. It hides most of the "Expect" machinery; the "Expect" object is available for tweaking if need be. Generally, one starts by creating an Expect::Simple object using new. This will start up the target program, and will wait until one of the specified prompts is output by the target. At that point the caller should send() commands to the program; the results are available via the before, after, match_str, and match_idx methods. Since Expect simulates a terminal, there will be extra " " characters at the end of each line in the result (on UNIX at least). This is easily fixed: ($res = $obj->before) =~ tr/ //d; @lines = split( " ", $res ); This is not done automatically. Exceptions will be thrown on error (match with "/Expect::Simple/"). Errors from Expect are available via the error_expect method. More human readable errors are available via the error method. The connection is automatically broken (by sending the specified disconnect command to the target) when the Expect::Simple object is destroyed. Methods new $obj = Expect::Simple->new( \%attr ); This creates a new object, starting up the program with which to communicate (using the Expect spawn method) and waiting for a prompt. The passed hash reference must contain at least the Prompt, DisconnectCmd, and Cmd elements. The available attributes are: Cmd Cmd => $command, Cmd => [ $command, $arg1, $arg2, ... ], The command to which to connect. The passed command may either be a scalar or an array. Prompt This specifies one or more prompts to scan for. For a single prompt, the value may be a scalar; for more, or for matching of regular expressions, it should be an array reference. For example, Prompt => 'prompt1> ', Prompt => [ 'prompt1> ', 'prompt2> ', -re => 'promptd+>s+' ] All prompts are taken literally, unless immediately preceded by a "-re" flag, in which case they are regular expressions. DisconnectCmd This is the command to be sent to the target program which will cause it to exit. RawPty If set, then underlying Expect object's pty mode is set to raw mode (see Expect::raw_pty()). Timeout The time in seconds to wait until giving up on the target program responding. This is used during program startup and when any commands are sent to the program. It defaults to 1000 seconds. Debug The value is passed to Expect via its debug method. Verbose This results in various messages printed to the STDERR stream. If greater than 3, it turns on Expect's logging to STDOUT (via the log_stdout Expect method. send $obj->send( $cmd ); $obj->send( @cmds ); Send one or more commands to the target. After each command is sent, it waits for a prompt from the target. Only the output resulting from the last command is available via the after, before, etc. methods. match_idx This returns a unary based index indicating which prompt (in the list of prompts specified via the "Prompt" attribute to the new method) was received after the last command was sent. It will be undef if none was returned. match_str This returns the prompt which was matched after the last command was sent. before This returns the string received before the prompt. If no prompt was seen, it returns all output accumulated. This is usually what the caller wants to parse. Note that the first line will (usually) be the command that was sent to the target, because of echoing. Check this out to be sure! after This returns the 'after' string. Please read the Expect docs for more enlightenment. error This returns a cleaned up, more humanly readable version of the errors from Expect. It'll be undef if there was no error. error_expect This returns the original Expect error. expect_handle This returns the Expect object, in case further tweaking is necessary. BUGS
If the command to be run does not exist (or not in the current execution path), it's quite possible that the new method will not throw an exception. It's up to the caller to make sure that the command will run! There's no known workaround for this. LICENSE
This software is released under the GNU General Public License. You may find a copy at http://www.fsf.org/copyleft/gpl.html AUTHOR
Diab Jerius (djerius@cpan.org) perl v5.12.4 2008-05-06 Expect::Simple(3pm)