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.

learn more… | top users | synonyms

0
votes
0answers
62 views

Send command to open process in Shell file

In bash how can I issue a command to a running process I just started? For example; # Start Bluez gatttool then Connect to bluetooth device gatttool -b $MAC -I connect # send 'connect' to the ...
3
votes
2answers
16k views

sftp a file using shell script

I have read through several threads (which have been helpful) and I'm still getting an error when trying to sftp a file (client wants it to be sftp'ed) Here is the script: #!/bin/bash HOST=XX.XX....
0
votes
1answer
22 views

Bash Expect Script Adding Additional Character to Password Input [closed]

I am writing an expect script to SCP a file from a switch. This will expectedly prompt for a password upon connecting the SCP. My code is as follows; #!/usr/bin/expect # Template for connecting SSH ...
1
vote
1answer
45 views

script ssh login to server and pass root password

I have written an expect script to automate the login process for ssh. My user account has rsa keys setup but once I log in I want to switch to root but the remote server is hanging on the password. I ...
1
vote
2answers
53 views

How to write expect in shell

This is continuation to my previous question :Spawn command not found After referring to few old posts, I have written those commands, If its wrong, then how I can run ssh to remote server and run ...
1
vote
1answer
42 views

Spawn command not found

I trying to use the spawn command to connect to remote server, execute some commands/script. Here is script: #!/usr/bin/expect for i in `srvctl status database -d PROD | awk -F " " '{print $(NF)}'` ...
0
votes
2answers
1k views

Use a script for a telnet session

I have a problem with my script. It seems my password is wrong. #!/usr/bin/expect set ip [lindex $argv 0] spawn telnet $ip set timeout 10 expect "Login:" send "administrator\r" expect "Password:" ...
0
votes
1answer
41 views

login to remote server using expect program

I have written an expect program (refer below:), where I am trying to copy files to remote machine. While scp'ing, if I provide wrong password, my expectation is second condition will be met and print ...
2
votes
1answer
76 views

Expect PECL for PHP 7

I just upgraded to PHP 7.0.3, but there is no support for expect. Does anyone know if is it possible to bypass the installation issue? It says: root@portal:/home# pecl install expect-0.3.3.tgz pecl/...
2
votes
0answers
37 views

Tcl/Expect: Can't set variable value correctly

I'm newbie in Tcl/Expect. I'm trying to get IPSec tunnel details from the router. After that fetch lines with IP addresses. So, I have follow code: send "show tunnel ipsec remote 10.10.10.10\r" ...
0
votes
2answers
223 views

Unable to execute bash script inside expect script

i have a expect script like #!/usr/bin/expect ..... spawn passwd expect "password:" send "password" .... .... .... ~/test.sh Wile executing this, I'm unable to run bash script test.sh. How to ...
1
vote
0answers
10 views

Configuring an alert when a program tries to interact with the user

Most programs in *nix-land take their options via the command line or through a configuration file. However, there are a few programs that do not have any such option, and will resort to interacting ...
0
votes
2answers
104 views

Bash using netcat, send one command's output to file

I need to know how to grab output and store it in a variable. I don't want to send all the output to the file, just one of the commands output I am sending.. Basically AUTH AUTH LIST <---needs to ...
1
vote
2answers
141 views

Using special character " and ` in send command in expect script

I am trying to execute a command in Linux servers to fetch which all servers requires root password reset as there are multiple servers I am using an expect script to automate it , my command contains ...
0
votes
2answers
68 views

Can I have a (bash) shell with expect running in the background?

I am trying to write an expect script that once started will watch my terminal and run a command every time that it finds a match. Is this even possible with expect? If so, would expect_background ...
3
votes
1answer
78 views

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/....
3
votes
2answers
7k views

grep output of expect script

I'm trying to run some expect language, and grep/parse the output all in one script. I want to grep the output of and look for "error" (I should note that standard linux commands like awk, sed, grep, ...
1
vote
1answer
77 views

Autoexpect hangs at the end of the script

I have an autoexpect script. I modified it and it works great, however when it finish to run it hangs and I need to do ctrl+C in order to get my terminal [..] 887VA#logout Connection to 10.255.255.1 ...
0
votes
3answers
6k views

“Expect” automation tool output to shell variable

#!/bin/bash # more commands here expect << EOD spawn telnet localhost 9151 expect -exact "Trying 127.0.0.1...\r Connected to localhost.\r Escape character is '^]'.\r" send -- "AUTHENTICATE $...
1
vote
0answers
53 views

Start a subshell then run commands

Say I have a script that is always run from an interactive shell. I would like this script to launch an interactive subshell that is a replica of the parent (i.e., all environment variables, etc. ...
1
vote
2answers
137 views

Cracking root user: Automating logging into root using “su” from nonroot user

I want to write a script that allows me to pass a password to the su command. The reason for this is to automate the process of logging into root from nonroot account. From my basic understanding of ...
3
votes
1answer
49 views

Expect to scp directory does not work when run from post commit

I am trying to implement a post-commit hook on svn which will scp some files from the svn machine to some other backup machine after each commit. I have written the script with expect as follows ...
0
votes
1answer
131 views

set variable in bash script with EXPECT

I have bash script which can login to Cisco switch and shut/noshut any port i have defined in it. what I want is that i can add variable , like i can define port number in command like this ./cisco....
2
votes
0answers
182 views

Installing Expect and TCL

I downloaded the source for expect5.45, and am attempting to install it. tclsh is on the system at /usr/bin/tclsh, but I'm not sure if that means the machine also has "tcl" installed? The ...
14
votes
3answers
74k views

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 ...
1
vote
1answer
23 views

Execute a script compiled on a different PC

If I have a compiled expect script, can I run it on a PC with no expect installed?
1
vote
1answer
174 views

Filename expansion for expect script within bash

I have the following bash script with an embedded expect script: #!/bin/bash if [ ! $# == 2 ] then echo "Usage: $0 os_base_version sn_version" exit fi if [ -e /some/file/path/$...
1
vote
1answer
505 views

Get the output from expect script in a variable

I have an expect script which provides the IP address: #!/bin/expect -f set nodename [lindex $argv 0] spawn virsh console $nodename expect "Escape character is" send "\n" expect "localhost login: " { ...
0
votes
1answer
128 views

Sending shell script command keystrokes to a remote shell

Is it possible to make the script run when it shifts from normal mode to the interactive mode. #/bash/bin sudo gatttool -b 80:EA:CA:00:00:03 -I # All these commands are typed in interactive mode ...
0
votes
1answer
52 views

Expect script: How to expect a literal * character instead of * as glob or regex character

I have an expect script that spawns a connection to hunspell to check the spelling of a word. Unfortunately, if the word is in the dictionary, hunspell simply sends back a *. How can I tell expect to ...
0
votes
1answer
76 views

Auto-inputing ssh password in shell scripts on Linux [duplicate]

I can use ssh command and provide password and connect to another server. But I need to pass password in the shell script. how?
0
votes
2answers
325 views

pexpect fails to match command is grater than 65 characters

Issue with pexpect, python module. Pexpect fails to do expected behavior if the length of the command is greater than 65. #!/usr/bin/python import pexpect sshCmd='ssh root@15.186.22.105' prompt='[...
0
votes
3answers
583 views

How to use expect in Bash script and ssh-copy-id

From a bash script: source ./expect.sh I am including a expect code: #!/bin/bash /usr/bin/expect <<EOL spawn ssh-copy-id -i /home/user/.ssh/id_rsa.pub 111.111.111 expect '*?assword*' send '...
3
votes
1answer
2k views

Calling an expect script in a loop of a bash scrip

I am trying to loop a list of sites through an expect script. The loop will take my list and read it line by line, change directories to the folder of the site name, then pass the site name to an ...
6
votes
2answers
12k views

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 ...
1
vote
3answers
1k views

pass parameters to bash script using chef attributes

I have a bash script ( let's say main.sh ) which I need to integrate with chef. Currently we are using "expect" to pass the parameters to main.sh. Now I need to make script in such a way that the ...
1
vote
1answer
290 views

Get only files modified within last 30 minutes using sftp get

Within a .sh script, I'm using expect to automatically sftp to another computer in order to get files. My script will be set to run every 30 minutes, at which point I want to get only files that were ...
1
vote
0answers
132 views

whether the ssh command successful or not?

I spawned ssh in expect script. in the script i have to check the exit status of ssh command on local machine to make some condition in that script using if/else. spawn ssh user@192.168.1.1 ...
2
votes
1answer
604 views

Expect Script for Command Line

I am writing a script that will allow a Linux admin to quickly change passwords of its users. #!/usr/bin/expect # Check password for strength # ---------------------------------------------- read -p ...
3
votes
2answers
15k views

script to automate scp in network

I have a network full of Linux machines. In this network, I have a user as user1 with the password as password in all the machines. I have the following script to put files in the home directory of ...
2
votes
1answer
312 views

Huge delay in script response when using SFTP with expect

I am using a script to call SFTP service to fetch some logs from the remote server. This works fine in normal scenario but, i have noticed a very long delay of around 30 minutes or more in some of the ...
0
votes
2answers
283 views

expect: does “” (spawn_id exp70) match glob pattern

I have written an expect script that works perfect for testing passwords on our network until it has looped through my list quite a bit, then the debug output shows that there is nothing to match. ...
6
votes
1answer
2k views

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. ...
0
votes
2answers
318 views

Expect Scripts - Reading from Files and Accepting User Input

How can I write an "Expect" script to: iterate over a list of IP addresses and log in to each to perform commands (like in a BASH for loop). Right now I just copy/pasted the few lines that are my ...
2
votes
3answers
2k views

How to automate connecting to multiple network devices, running a command and saving the output to a file?

I have to run a command on around 1000 network devices and save the output to a file. In a file I have a list of all the network device names that have to be connected to using SSH. I then have to run ...
1
vote
2answers
675 views

how to continue bash script execution when expect part is finished

I have bash script and inside it part with expect code: #!/bin/bash set -ex funct() { pass3="some_pass" expect -c " spawn su - oracle expect "Password:" send \"$pass3\n\" ...
5
votes
2answers
834 views

scp command behaves differently when used with expect utility

expect -c 'spawn scp -C -o CompressionLevel=9 ~/partFiles/* abc@10.200.4.15:/export/home/abc/; sleep 10; expect password; send "secretPassword\n";interact' throws - ~/partFiles/*: No such file or ...
2
votes
2answers
535 views

Regular expressions with ExpectJ

I've been used the ExpectJ Java library to automate some jobs on a Linux server, however now I need to automate a job that sends a different text response for each execution. Here is the output: Last ...
1
vote
0answers
396 views

Why the output is not written to log from expect script

I am trying to write the output of the netcat command including the command also to a file by logging into remote servers. But it is not writing. What am I missing ? #!/usr/bin/expect -f set user [...
6
votes
3answers
16k views

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