Automating Tasks with EXPECT

Mr. Saladino gives a quick introduction to EXPECT, a program to help you accomplish your remote tasks.
______________________

Comments

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

interact hangs out when I cat a large file

Anonymous's picture

Hi,

I would like to know whether there is any fix for to prevent interact command from hanging out when I cat a large inside a expect spawned process. Send in your reply to gururaj.srinivasarao@gmail.com

I found an amazing tutorial

Anonymous's picture

you can check out this amazing tutorial its the best
http://exploring-expect-tcl.blog.com/2009/06/03/exploring-expect/

Very Good knowledge shaired

Shailesh's picture

Thanks.
This is very good for system admins.

How to write regular expression for welcome message?

Anonymous's picture

After login welcome message shows date and time .. How do we write RE for it ? Any idea.

TIA

Thanks !!! It helped me alot

Anonymous's picture

Thanks !!! It helped me alot !!!!!

Expect buffer

Anonymous's picture

Hello,

I want to know the size of expect_out(buffer).I want large amount of data to be moved to file using expect buffer but match_max did not help.

Can you please suggest me solution?

Thanks,
pankaj

Telnet session on a telnet session through EXPECT

Sapnesh's picture

Hi All,

I want to telnet to server A followed by another telnet to Server B from Server A.

I could create the expect scripts to telnet to a single server. But then if i send command 'send "telnet server B\r"`to Server A, it doesnot respond properly.

Please Help. do i need to spawn the second telnet process? If yes, then how would i pass the spawn id information back to local machine.

ThanksInAdvance,
Sapnesh

Your guide is very helpfull

rozi's picture

Hi,
I'm seeking the guide that can help me solveing the auto task rather than crond. Now i found it. Great help!

Great solution

Chuck D Smith's picture

This article gave us a great hint to creating a solution to rebooting a Perle Specialix Jetstream terminal server for a failover test. The 'autoexpect' utility gave us the solution we needed in 5 minutes after we found the article. Great stuff! And the article is 8 years old at that!
Please renew my subscription... Oh yeah I just did renew it...

Great help! Thanks!

Anonymous's picture

Great help! Thanks!

Re: System Administration: Automating Tasks with EXPECT

Anonymous's picture

It was a great info I was earlier looking for!
Long live :-)
Kumar

Re: System Administration: Automating Tasks with EXPECT

Anonymous's picture

How to automate telnet through this autoexpect.....can someone help me out....

thanks in advance

S.Sriram

Automating Telnet with expect

Yash's picture

Hi Sriram,

This is too easy.

Just type

$ autoexpect -f telnet.exp telnet

and then enter your username and password
execute any command if u want on remote machine. Then finally exit.

After this telnet.exp file will be created.
Open telnet.exp file and delete the lines containing time stamp for your login. Save the changes. And run ./telnet.exp.

Hope this helps :)
Yash

Re: System Administration: Automating Tasks with EXPECT

Anonymous's picture

this acticle is too sample to help someone understand the Expect

Re: System Administration: Automating Tasks with EXPECT

Anonymous's picture

you just have to do :

autoexpect telnet X.X.X.X

then do like you were doing a standart telnet, enter all the command you need.

then, quit the telnet and a script will be generated in your folder.

juste lunch the script to see what you do before.

I hope it will help you.

Phil.

I was just wondering if

Anonymous's picture

I was just wondering if anyone knew how to make the ip address you are telnet into a variable. I am using a script that was created by the autoexpect feature, but i want to be able to choose the ip address i am going to telnet. thanks for your help.

Telnet - variable IP

George Shelton's picture

Here you go, Host name or IP will work.

# Get the Host name that you are going to work on

send_user "Input Host name here: "

expect_user -re "(.*)\n" {set HostName $expect_out(1,string) }

send_user "\n"
spawn telnet $HostName

Webinar
One Click, Universal Protection: Implementing Centralized Security Policies on Linux Systems

As Linux continues to play an ever increasing role in corporate data centers and institutions, ensuring the integrity and protection of these systems must be a priority. With 60% of the world's websites and an increasing share of organization's mission-critical workloads running on Linux, failing to stop malware and other advanced threats on Linux can increasingly impact an organization's reputation and bottom line.

Learn More

Sponsored by Bit9

Webinar
Linux Backup and Recovery Webinar

Most companies incorporate backup procedures for critical data, which can be restored quickly if a loss occurs. However, fewer companies are prepared for catastrophic system failures, in which they lose all data, the entire operating system, applications, settings, patches and more, reducing their system(s) to “bare metal.” After all, before data can be restored to a system, there must be a system to restore it to.

In this one hour webinar, learn how to enhance your existing backup strategies for better disaster recovery preparedness using Storix System Backup Administrator (SBAdmin), a highly flexible bare-metal recovery solution for UNIX and Linux systems.

Learn More

Sponsored by Storix