07-30-2011
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
9 More Discussions You Might Find Interesting
1. UNIX for Dummies Questions & Answers
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
2. Shell Programming and Scripting
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
3. Shell Programming and Scripting
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
4. AIX
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
5. Shell Programming and Scripting
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. Shell Programming and Scripting
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
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
8. Shell Programming and Scripting
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
9. Shell Programming and Scripting
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
LEARN ABOUT DEBIAN
xrlogin
XRLOGIN(1) General Commands Manual XRLOGIN(1)
NAME
xrlogin - start an xterm that uses ssh (or optionally rlogin or telnet) to connect to a remote host
SYNOPSIS
xrlogin [-l username] [-rlogin|-telnet] [xterm options] remote-host
DESCRIPTION
Xrlogin opens an xterm window and runs ssh, rlogin or telnet to login to a remote host.
Xrlogin automatically passes the -name argument to xterm with a value of "xterm-hostname" where hostname is the name of the remote host.
This allows the user to specify resources in their server's resource manager which are specific to xterms from a given host. For example,
this feature can be used to make all xterm windows to a given remote host be the same color or use a specific font or start up in a spe-
cific place on the screen. Xrsh(1) passes the same string so they are compatible in this regard.
Xrlogin specifies that the default title for the new xterm will be "hostname" where hostname is the name of the remote host. This and the
-name argument above can be overridden with xterm-options on the command line.
One could also use xrlogin's sister command xrsh(1) to open a window to a remote host. In the case of xrsh, the xterm would run on the
remote host and use X as the connection protocol while xrlogin would run the xterm on the local host and use rlogin or telnet as the con-
nection protocol. See xrsh(1) for a discussion of the merits of each scheme.
OPTIONS
-l username
When not using -telnet, use username as the id to login to the remote host.
-rlogin
Use the rlogin protocol to open the connection. In general rlogin is preferred because it can be configured to not prompt the user
for a password. Rlogin also automatically propagates window size change signals (SIGWINCH) to the remote host so that applications
running there will learn of a new window size.
-telnet
Use the -telnet protocol to open the connection. Use of telnet provided mostly for hosts that don't support rlogin.
COMMON PROBLEMS
Make sure that the local host is specified in the .rhosts file on the remote host or in the remote hosts /etc/hosts.equiv file. See
rlogin(1) for more information.
EXAMPLES
xrlogin -bg red yoda
Start a local red xterm which connects to the remote host yoda using rlogin.
xrlogin -telnet c70
Open a local xterm which connects to the remote host c70 using telnet.
SEE ALSO
xrsh(1), rlogin(1), telnet(1)
AUTHOR
James J. Dempsey <jjd@jjd.com> and Stephen Gildea <gildea@intouchsys.com>.
X Version 11 Release 6 XRLOGIN(1)