Questions tagged [expect]

Expect is a Unix/Linux extension for the Tcl scripting language. It was designed as an automation and testing tool and it makes it trivial to interact with complex programs, such as remote shells, security maintenance. It has particularly powerful response recognition.

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

305 questions
35
votes
12 answers

Shell Script for logging into a ssh server

I tried writing a shell script which can do automatic login into a ssh server using password which is mentioned in the script. I have written the following code: set timeout 30 /usr/bin/ssh -p 8484 [email protected] expect { …
pradeepchhetri
  • 9,859
  • 12
  • 51
  • 59
21
votes
3 answers

bash script error stty: standard input: Inappropriate ioctl for device

I'm using here-documents in a bash script to automate installation and setup where a password is required many times. I enter the password once and the script passes it to the various commands. In most instances the here-document approach handles…
MountainX
  • 17,168
  • 59
  • 155
  • 264
20
votes
3 answers

spawn - command not found!

I am using Mac OS X 10.9.4, following is my script to copy files from local machine to different host #!/bin/bash #!/usr/bin/expect echo "I will fail if you give junk values!!" echo " " echo "Enter file name: " read filePath echo " " echo "Where…
dev2d
  • 303
  • 1
  • 3
  • 7
14
votes
1 answer

Can I build a Docker container from Dockerfile in an interactive way with allocation of some pseudo TTY?

I build container from below Dockerfile: FROM ubuntu:14.04 ... RUN apt-get update && apt-get install -y vim #RUN ssh-keygen -f /root/.ssh/id_rsa -N strongpass123$%^ RUN ssh-keygen -f /root/.ssh/id_rsa ... I do it quite rarely, but there is many…
koralgooll
  • 305
  • 2
  • 5
13
votes
4 answers

What happens if I start too many background jobs?

I need to do some work on 700 network devices using an expect script. I can get it done sequentially, but so far the runtime is around 24 hours. This is mostly due to the time it takes to establish a connection and the delay in the output from these…
KuboMD
  • 409
  • 6
  • 16
10
votes
2 answers

Removing non printable characters from expect logs?

How can I either strip the following character sequences from my files? ^[[64;8H, ^[[?25h, ^[[1;64r etc or avoid having expect add them in the first place? Background: I'm using a collection of expect scripts for certain tasks. The output files I'm…
Tim Brigham
  • 1,017
  • 1
  • 13
  • 22
9
votes
1 answer

bash and expect in the same script?

I'm trying to code an script that takes IP addresses from a .csv file and telnet the device to catch "show version" command output. So far I have coded this: #!/bin/bash #!/usr/bin/expect -f FILE1=dispositivos.csv #file with IP's and device…
8
votes
1 answer

Why is expect's interact command not working?

I am trying to automate gdb with expect. My script will start gdb, do some initialisation, and then pass the control to the user. Expect's interact command seems like the perfect tool for the job. Now consider: $ echo "spawn gdb expect \"(gdb)…
7
votes
2 answers

How do I use 'expect' to read the contents of a file into a variable?

I am having troubles writing an expect script. I want to do something equivalent to the following bash instruction: iplist=$(cat iplist.txt) I've tried using set in all the ways that I know but it is still not working. Is there another way or is…
7
votes
2 answers

Create a directory if it doesn't exist in TCL

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
  • 6,973
  • 19
  • 64
  • 80
6
votes
2 answers

sudo askpass: ask from other tty

Context I want to setup rsync backups of my server, so I run the following command rsync -r -e ssh --rsync-path="sudo rsync" [email protected]:/ /backup/ Ideally, that command would ask my private ssh key password, then connect, then ask the…
Suzanne Soy
  • 486
  • 5
  • 13
6
votes
2 answers

Cross compiling expect for ARM

I have downloaded expect5.4 . I'm trying to cross compile it for ARM(PandaBoard) running stripped down version of linux. In the initial setup of configuring , I try Shell$ ./configure --host=ARM configure: WARNING: If you wanted to set the --build…
m4n07
  • 181
  • 1
  • 1
  • 4
6
votes
2 answers

How do I expect a newline in expect script?

Consider this interactive script: #!/usr/bin/env bash set -eu while true; do read -p '> ' if [ "$REPLY" == quit ]; then break fi echo "'$REPLY'" done Now I want expect to interact with it: #!/usr/bin/env bash set -eu echo ' …
x-yuri
  • 3,223
  • 10
  • 39
  • 62
5
votes
1 answer

error handling in expect?

I am just improving my question because I have achieved so far up to this: set username [lindex $argv 0] set password [lindex $argv 1] set hostname [lindex $argv 2] if {[llength $argv] == 0} { send_user "Usage: scriptname username \'password\'…
munish
  • 7,825
  • 24
  • 71
  • 97
5
votes
1 answer

Unix AIX passing variable and arguments to expect and spawn

I am writing a script to scp some files but need to pass file location through the user or another script as an argument #!/usr/bin/expect set FILEPATH1 $1 spawn sh "scp $FILEPATH1 $USER@$HOST:/destination/files" set pass "pass123" …
OmAr
  • 51
  • 4
1
2 3
20 21