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.
63 questions
0
votes
0
answers
112
views
expect script inside bash doing remote ssh /etc/sudoers replacement
I am having issues with the below script. I am trying to replace a line in /etc/sudoers file but need to do it using sudo and either input my password or as in example here, put it in a variable.
#!/...
0
votes
0
answers
69
views
set timeout -1 is endless and not executing
I have an expect script that helps me during installation of a certain file. The installation process includes a couple of [yes/no] questions and then the actual installation begins.
The [yes/no] ...
0
votes
0
answers
768
views
How to display output from expect?
I'm trying to read data from a machine that uses a telnet style interface using expect. An interactive telnet session works like this:
% telnet 10.92.177.14 53595
Trying 10.92.177.14...
Connected to ...
7
votes
1
answer
1k
views
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 ...
0
votes
1
answer
164
views
What's the best way to replay keystrokes on to my terminal?
I find myself having to do a series of ssh in order to get to a particular host. What I currently do is to copy and paste the commands into the terminal, one after the another, like a machine. I'm ...
0
votes
1
answer
514
views
expect spawn command: Escaping newline (\n) in string
I am trying to use expect to interact with the MATLAB console. Currently I have:
#!/usr/bin/expect -f
spawn {*}/usr/bin/run.sh matlab -r "fprintf(1, \"The identifier was:%s\\\\n\", \&...
2
votes
1
answer
7k
views
expect -timeout vs. "set timeout" in expect: Different behavior
I was testing a expect script and found two different behaviors when using set timeout vs. expect -timeout. Here is a simple example
response.sh:
#!/usr/bin/bash
sleep 2
echo hello
test1.sh:
#!/usr/...
0
votes
1
answer
830
views
how to use expect into bash to automate installation
I have a bash that answers the questions that freefilesync asks during installation, using expect:
#!/bin/bash
tar -xf FreeFileSync*.tar.gz
mv FreeFileSync*.run FreeFileSync.run >/dev/null 2>&...
1
vote
1
answer
3k
views
passing bash variables to expect script or scripting expect from inside bash
This script is intended to mount the contents of my server at home as a read/writeable drive in mac os. Unfortunately due to the fact that my house has a dynamic public ip address, the ip address of ...
0
votes
1
answer
1k
views
Eternal loop with expect
I want this expect script to run forever (or until "ok" is printed), however it does not and exits right away.
#!/usr/bin/expect
set timeout 180
spawn ssh -o "StrictHostKeyChecking no&...
0
votes
2
answers
707
views
For cycle with expect and variable evaluation
I want to execute a script remotely with expect and a for loop:
#!/usr/bin/expect
set timeout 10
spawn ssh [email protected]
expect "password: "
send "pass\n"
expect "$ "
...
0
votes
1
answer
6k
views
How to set up and use a variable within a single-line “expect” command in a Bash script?
I have an array, $HOSTS, which contains a set of hostnames. I have a database table that has a set of IP addresses. I want to go through each IP address in that table and send a command (hostname -s) ...
0
votes
1
answer
2k
views
Expect script - sometimes no log generated
I have a simple expect script that supplies password 4 times.
I am logging the output to a log file using
log_file -a /home/applusr/e291505/logs/ADD.log
spawn /home/root/admin/add.mims.user $...
0
votes
0
answers
246
views
Is it possible to detach and re-attach to a spawned process using separate expect processes?
I have an expect script that spawns a process, then does some initialization (authentication), then performs some task that needs prior authentication.
Considering to extend the script to execute ...
0
votes
1
answer
322
views
spawn, expect, send aborts during scp transmission
I have a basic scp sending mechanism with spawn, expect and send.
However it gets aborted during the scp transmission.
Here is the expect command:
expect -c "spawn sh -c {scp -r -P 22 /tmp/rootfs/* ...