EXPECT script for Telnet automation. Need your support.


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting EXPECT script for Telnet automation. Need your support.
# 1  
Old 07-30-2011
Bug EXPECT script for Telnet automation. Need your support.

Dear experts, please help me .

I've found simple EXPECT scripts and all works fine. But I need more automation in error handling and sending list of commands/output logging from multiple remote hosts.

I have 10 hosts, for example:
host1 192.168.1.1 LOGIN1 PASSWORD1
...... ................ ........ ................
host10 192.168.5.16 LOGIN10 PASSWORD10


For me better to put these addresses and credentials to special "my_hosts" file in ~/scripts/teln/config/ directory.

Also I have a few files () with only sets of commands for remote hosts, for example:

enable
sh runn
con ter
br
en

I need expect script with 2 parameters: "Hosts list" file name and "Commands list for remote hosts" file name which can run this list of commands in all hosts (sequent, host by host) and put only telnet log to separate log files - one per host and/or one per command type.

Also I need every command from "Commands list for remote hosts" to be executed in cycle - to evaluate/expect for error printout and finish/halt script with line number of wrong command in
"Commands list for remote hosts".

If "Stop on error", "Delay between commands" options will be available as CL parameters and in some .config file - it will be great.

I understand that this script is not possible with my dummy level but hope to get some useful information, support from you.

Thanks you in advance!

BR,
Alexander




---------- Post updated at 05:59 PM ---------- Previous update was at 03:17 PM ----------

Dear experts,

solution is found.

Please search: Automated_Remote_VTY_Command_Script
# 2  
Old 08-02-2011
The expect telnet is so funky by itself for one host, it would be better to use either a wrapper shell script or a script generator shell script to apply it to a list of hosts/ports/command_sequences.
# 3  
Old 08-12-2011
Java

hi startchen,

can you share the script with me u alread have. i may can twork on and ammend it as i am looking to do the same thing but struggling.

Cheers
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

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

2. Shell Programming and Scripting

Expect While Loops - Partial Automation?

I've been reading the O'Reilley expect book and I'm trying to create partial automation for common questions asked on screen in a telnet session and return to interact so the user can resume control. For example while {1} { expect { -re "What color is the sky?" {send... (0 Replies)
Discussion started by: mlarivie
0 Replies

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

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

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

6. AIX

Automation from Windows to Linux - Telnet and su using perl

Here is my requirement to automate the deployment procedure for my project. Telnet to AIX box (say SERVER1) from windows machine (with USER1) Select the server to login say "SERVER2" su as different user say "USER2"(Owner of the deployed files) Execute the script (Script has so many... (1 Reply)
Discussion started by: nurainos
1 Replies

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

8. Shell Programming and Scripting

Run expect script in systems that don't support it out of box

Noob question .. My Java based application needs to change some user passwords based on some user actions. Since this application can run on Redhat AS2.1 / AS4.0 / Solaris 9 etc, the most safe and portable solution that I could think of was: Use expect. Now, expect is not available on all... (1 Reply)
Discussion started by: namityadav
1 Replies

9. UNIX for Dummies Questions & Answers

Automation of telnet and ftp

I have a basic query. I use telnet and ftp very frequently. I want to do it without spending time in typing username and password everytime. I know that if I have .netrc file which contains server address, username, pasword, then just typing ftp will conect to that server with that username and... (10 Replies)
Discussion started by: asutoshch
10 Replies
Login or Register to Ask a Question