Questions tagged [expect]

Expect is a utility based on TCL. It's primary use is for building automation into interactive environments such as telnet or ssh based terminal environments. It provides the ability to enter commands on a command line and interpret the output.

Expect adds many extensions to the Tcl scripting language which simplify scripting interactive applications controlling such hard-to-interact programs such as telnet, ftp, passwd, fsck, rlogin, tip, ssh, and others. Expect/tcl can run a GUI interface or run from the command line. Since Tcl is a full featured programming language, Expect can easily interact with databases, webservers, etc. with intuitive, powerful, and easy-to-anticipate processing.

Expect is in the public domain. There is full support for Linux and Windows.

Overview and history website: http://www.nist.gov/el/msid/expect.cfm
Support and download website: http://expect.sourceforge.net/
FAQs website: http://expect.sourceforge.net/FAQ.html

60 questions
14
votes
1 answer

What is the meaning of the "spawn" command in Linux (Centos6)

I need to know how to set up a cron job that automatically connects to a remote server, then changes to a directory and downloads all the files in that directory to local. I think I have to use SFTP but I saw the following command using "spawn" in…
user1179459
  • 243
  • 1
  • 2
  • 8
8
votes
1 answer

Can Expect make sure a certain log does not appear?

Expect scripting is great for writing tests that are basically "make sure that running this command causes these logs to be printed". Expect lets you skip past the irrelevant output and look for specific lines in the logs. Is there a way to make…
Woodrow Barlow
  • 401
  • 1
  • 4
  • 17
5
votes
3 answers

How to by-pass user interactions in a script?

I am trying to automate the installation of a program through a shell script. There are a few steps which require user interaction from the command line (confirmation, yes/no, etc.). What is the best way to by-pass it? I know that one possibility is…
Vignesh
  • 53
  • 1
  • 1
  • 3
5
votes
1 answer

Which characters require escaping in expect strings?

I know that hard brackets [, ] require triple backslash escaping when used inside expect "..." strings, so I use expect "blah blah \\\[herp derp\\\]" to accurately convey these characters to the expect I/O checker, but what other characters also…
mcandre
  • 3,026
  • 5
  • 39
  • 61
3
votes
3 answers

Automating an ssh connection with crontab

I've been struggling to crontab automate a git push process with ssh, and it's proving tricky to setup a key with the ssh agent. Starting with a basic script to test the agent: # set paths (all examples) source /etc/profile export…
geotheory
  • 1,069
  • 3
  • 14
  • 28
2
votes
1 answer

expect + how to verify if dir exists and if not how to create it

I write expect script that login to remote machine and run there some scripts But I need also to verify the following Verify if directory /var/cti/adm/APP exists If APP not exists under adm directory , then need to create this directory and add…
maihabunash
  • 489
  • 2
  • 6
  • 15
2
votes
1 answer

expect command in ubuntu

I've searched all over SuperUser, but couldn't get the solution. Here is a script that am using for ssh using expect. I'm using ubuntu and I've installed expect using aptitude install expect. #!/usr/bin/expect -f spawn ssh user@server expect…
CodZilla
  • 23
  • 1
  • 3
2
votes
2 answers

couldn't execute "mysql": no such file or directory, using autoexpect

I have the following file: exp.exp #!/usr/bin/expect db_host='localhost' db_name='webui_dev' db_user='root' db_pass='rootpass' new_db_name='db_2011' expect <
Andrey Yasinishyn
  • 123
  • 1
  • 1
  • 3
2
votes
2 answers

Bash/expect script to log in via ssh and port knocking. SSH Keys not possible

My login server is behind a firewall that uses port knocking to allow entry. The login-flow is Enter in port knocking command. This requires my external IP to be entered. When prompted, enter in my port-knocking password. Enter in ssh command Enter…
Zach Melnick
  • 143
  • 4
2
votes
2 answers

Installation of Expect on Windows 7 64-bit fails with "not found in the archives"

Downloaded ActiveTcl from http://www.activestate.com/activetcl/downloads/ Installed ActiveTcl at c:/Tcl/ Go to Bin directory in command prompt (Start > Run > cmd > cd c:\Tcl\bin) To install Expect, I executed the command teacup install Expect I…
Master James
2
votes
1 answer

How can I set up nautilus to use a ssh connection established by an expect script?

In order to automate a ssh connection, I wrote a script using expect, which works just fine. However, I would like to use this script in the nautilus connect to server function. My idea was to include this expect script somehow into the .ssh/config…
1
vote
1 answer

Expect script for telnet communication with DLink router

I am trying to connect to my router through telnet using this script: #!/usr/bin/expect -f set timeout 20 # router user name set name "admin" # router password set pass "admin" # router IP address set routerip "192.168.1.1" # Read command as…
shivams
  • 1,704
  • 1
  • 16
  • 26
1
vote
1 answer

sending GREP command fails

I'm new to expect scripting and trying to get below script to work. The script logs in to a server and reads a config file ($val in the script) for the values of "cps" and then presents a total value, but got stuck when sending a long "grep" command…
Dalman
  • 11
  • 1
1
vote
1 answer

file exists not working in expect script

I'm trying to check if a particular line exists in filename on a host. So only if the particular pattern is found from the grep command a dummy.txt will be created. Then I want to check if dummy.txt exists as a condition and proceed. But even though…
user417721
  • 41
  • 1
  • 5
1
vote
1 answer

Timeout does not work in expect script

I created the following expect script in order to automate logging into a VPN: #!/usr/bin/expect set PASS [lindex $argv 0] set timeout 10 spawn vpnc expect : {send $PASS\r} expect eof However, when I give wrong password…
1
2 3 4