10 More Discussions You Might Find Interesting
1. Red Hat
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
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
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
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
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
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
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
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
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
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
Net::CLI::Interact::Manual::Cookbook(3pm) User Contributed Perl Documentation Net::CLI::Interact::Manual::Cookbook(3pm)
NAME
Net::CLI::Interact::Manual::Cookbook - Miscellaneous recipes
Windows Support
The library works just fine under native windows (i.e use something like Strawberry Perl - no need for cygwin), for Telnet, Serial and SSH
connections. However one additional step is required for you to have success:
You must download the "plink.exe" application, and pass its filesystem location in the "app" parameter to "new()". Do not try to use any
other Telnet or SSH programs (for instance the Windows bundled "telnet") - they will not work. Here's an example:
my $s = Net::CLI::Interact->new(
personality => "cisco",
transport => "Telnet",
(Net::CLI::Interact::Transport::is_win32() ?
(app => "$ENV{HOMEPATH}\Desktop\plink.exe") : () ),
);
Unix Support
The library works fine on most Unix platforms. It will try to use the native "telnet", "ssh" (openssh) and "cu" programs for Telnet, SSH
and Serial connections, respectively. If you want to use another application, pass it in the "app" parameter to "new".
In some Unix environments there can be zombie child processes left around after running your script. If this happens, set the "reap"
option, like so:
my $s = Net::CLI::Interact->new(
personality => "cisco",
transport => "Telnet",
connect_options => {
reap => 1,
},
);
Phrasebook Entries
Prompts
These are nothing more than named regular expressions:
prompt configure
match /(config[^)]*)# ?$/
Macros
This example waits for the device to ask "[startup-config]?" and then responds with the text "startup-config".
macro copy_run_start
send copy running-config startup-config
match /Destination filename [startup-config]?$/
send startup-config
To send instead a press of the Return key (output record separator), use:
macro write_mem
send copy running-config startup-config
match /Destination filename [startup-config]?$/
send ''
To instead allow the user to pass in the file name, use a "sprintf" format.
macro save_to_file
send copy running-config startup-config
match /Destination filename [startup-config]?$/
send %s
The user must then pass a parameter to the "macro" call, even if it's an empty string:
$s->macro('save_to_file', { params => ['file_name'] });
# or
$s->macro('save_to_file', { params => [''] });
Continuations
These are Macros which start with a match instead of a send:
macro more_pages
match / --More-- /
send ' '
Note that the parameter of the "send" is not sent with a Return character (output record separator) appended.
When included in a macro, the continuation can be in-line, like this:
macro show_ip_route
send show ip route
follow / --More-- / with ' '
Running Commands
Standalone Commands
Simply send the command you wish to execute to the library. If not already done, a connection to the device will be established
automatically:
$s->cmd('show ip int br');
Normally this matches against a default prompt, which has been discovered automatically, or set by you:
$s->set_prompt('user_prompt');
It's also possible to pass in a custom prompt for this command only:
$s->cmd('show ip int br', { match => qr/special prompt>$/ });
Composite Macro Commands
Call a predefined Macro from the phrasebook using this method:
$s->macro('write_mem');
Sometimes the Macro needs parameters:
$s->macro('to_priv_exec', { params => ['my_password'] });
You can't really create a Macro on the fly very easily, but with suitable use of "cmd()", "set_prompt()", and the "match" option to "cmd()"
it's possible to achieve some simple flexibility.
Reconfiguring On-the-Fly
Phrasebook
It's possible to load a new phrasebook by the following method, which must be passed at least the name of the personality:
$s->set_phrasebook({ personality => 'ios' });
You can pass any options which the Phrasebook module itself would take.
Prompt
The current prompt can be changed by passing the name of the new Prompt as it is known by the phrasebook:
$s->set_prompt('name');
If you want to test whether the current prompt matches a diffrent named Prompt from the phrasebook, this method can be used:
$s->prompt_looks_like('name');
perl v5.14.2 2012-06-12 Net::CLI::Interact::Manual::Cookbook(3pm)