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
1answer
38 views

Capture stdout from ssh session to local machine

I am having to put together a script that will ssh into devices to run a command such as "show running-config" and save the output to a file on my local machine. I have done similar tasks like this ...
1
vote
2answers
51 views

Log the output of Expect command

I have made the below expect script and I need to log the output of that script. SOURCE_FILE=`ls -l *.txt --time-style=+%D | grep ${DT} | grep -v '^d' | awk '{print $NF}' ` if [ -n "${SOURCE_FILE}" ] ...
1
vote
1answer
37 views

`Interact` not working as expected in bash/expect scripting

In order to provision an embedded device (i.e. writing images to flash) a series of very well known commands have to be entered during the boot stage. The algorithm is something like: Capture a ...
0
votes
0answers
47 views

Regular expression in expect command

I need to match a string and a newline with a regular expression or something like split when using the expect command on Linux. Here is the example of the command output: Notification value: 34 39 ...
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
28 views

Expect Script - bash script file not found [closed]

My expect script #!/usr/bin/expect -f #I tried replacing sh - with bash -s still no positive results spawn ssh xxxx@yyyy "sh -" < test.sh expect "password: " send "zzzzz\r" expect "$ " This ...
0
votes
1answer
47 views

Expect Rsync with Double quotes

Below is my code: #!/usr/bin/expect -f set timeout -1 spawn rsync -arvz -e 'ssh -p 1690' --protect-args --progress /home/pappu/ 'backup@xx.xx.xx.xx:/volume1/56 - Backup Server/pappu' expect "password:...
0
votes
0answers
81 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....
1
vote
1answer
67 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
69 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
50 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
1answer
44 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
91 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
46 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
384 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
143 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
198 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
70 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
120 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
91 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
57 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
150 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
56 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
164 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
225 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
78k 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
195 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
659 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
145 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
55 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
81 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
368 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
643 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
13k 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
2k 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
312 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
152 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
750 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
16k 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
349 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
295 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
343 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 ...