Sponsored Content
Full Discussion: telnet commands using expect
Top Forums Shell Programming and Scripting telnet commands using expect Post 302380562 by pistachio on Tuesday 15th of December 2009 01:49:59 PM
Old 12-15-2009
Data 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 same variable in the command i want to send to the remote host.
Please help i am unable to do soo..


Code:
set timeout -1
send "file=cat /root/scripts/file.txt\r"
spawn telnet 172.XX.XXX.XX
match_max 100000
expect -exact "Trying 172.XX.XXX.XX...\r\r
Connected to 172.XX.XXX.XX (172.XX.XXX.XX).\r\r
Escape character is '^\]'.\r\r
Pragma Systems Inc.\r
Welcome to Pragma TelnetServer\r
(C) Copyright 1994-2005 Pragma Systems, Inc.\r
\r
login name: "
send -- "john\r"
expect -exact "john\r
password: "
send -- "S"
expect -exact "*"
send -- "w"
expect -exact "*"
send -- "o"
expect -exact "*"
send -- "r"
expect -exact "*"
send -- "d"
expect -exact "*"
send -- "@"
expect -exact "*"
send -- "f"
expect -exact "*"
send -- "i"
expect -exact "*"
send -- "s"
expect -exact "*"
send -- "h"
expect -exact "*"
send -- "\r"
expect -exact "\r
Windows NT Domain: "
send -- "\r"
expect -exact "\r
\r
User Account verification is being performed. Please Wait.\r
\r
\r
Terminal Type ?\r
1.) vtxxx\r
2.) ansi\r
3.) wyse 60 and above\r
4.) wyse-50\r
5.) ibm3151\r
\r
Please choose(1-5): "
send -- "\r"
expect -exact "\r
Client reported TERM=xterm\r
[?7h\r
Microsoft Windows \[Version 5.2.3790\]\r
(C) Copyright 1985-2003 Microsoft Corp.\r
\r
c:\\winnt\\profiles\\john>"
send -- "mml iofat:file=$file,nf;\r"
send -- "exit\r"
expect eof


Last edited by Scott; 12-15-2009 at 02:59 PM.. Reason: Please use code tags
 

10 More Discussions You Might Find Interesting

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

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

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

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

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

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 ...... ... (2 Replies)
Discussion started by: starchen
2 Replies

10. 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
qmail-control(5)						File Formats Manual						  qmail-control(5)

NAME
qmail-control - qmail configuration files INTRODUCTION
You can change the behavior of the qmail system by modifying qmail's control files in /var/lib/qmail/control. qmail can survive with just one control file, me, containing the fully-qualified name of the current host. This file is used as the default for other hostname-related control files. Comments are allowed in badmailfrom, locals, percenthack, qmqpservers, rcpthosts, smtproutes, and virtualdomains. Trailing spaces and tabs are allowed in any control file. The following table lists all control files other than me. See the corresponding man pages for further details. control default used by badmailfrom (none) qmail-smtpd bouncefrom MAILER-DAEMON qmail-send bouncehost me qmail-send concurrencylocal 10 qmail-send concurrencyremote 20 qmail-send defaultdomain me qmail-inject defaulthost me qmail-inject databytes 0 qmail-smtpd doublebouncehost me qmail-send doublebounceto postmaster qmail-send envnoathost me qmail-send helohost me qmail-remote idhost me qmail-inject localiphost me qmail-smtpd locals me qmail-send morercpthosts (none) qmail-smtpd percenthack (none) qmail-send plusdomain me qmail-inject qmqpservers (none) qmail-qmqpc queuelifetime 604800 qmail-send rcpthosts (none) qmail-smtpd smtpgreeting me qmail-smtpd smtproutes (none) qmail-remote timeoutconnect 60 qmail-remote timeoutremote 1200 qmail-remote timeoutsmtpd 1200 qmail-smtpd virtualdomains (none) qmail-send SEE ALSO
qmail-inject(8), qmail-qmqpc(8), qmail-remote(8), qmail-send(8), qmail-showctl(8), qmail-smtpd(8) qmail-control(5)
All times are GMT -4. The time now is 10:49 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy