Questions tagged [expect]
80 questions
3
votes
2 answers
Simple EXPECT script to execute remote command and displat output
I am trying to connect to a network router and execute show status on it.
Currently i am using:
spawn ssh -o StrictHostKeyChecking=no admin@192.168.20.254
expect " * ? password:*\r"
send -- "secretPassword\r"
sleep 5
send -- "show status\r"
sleep…

s.mihai
- 1,511
- 6
- 24
- 27
3
votes
3 answers
Expect Script wait Command Hangs
I have an expect script embedded in a bash script:
#! /bin/bash
# this function runs a command like 'ssh' and provides the password
function with_password {
expect << END
spawn $2
expect *assword:*
send -- $1
interact
wait
END
}
# run…

aaron
- 741
- 3
- 10
- 19
3
votes
2 answers
Why is `slapconfig -backupdb` not creating disk image when run from cron on Snow Leopard Server?
Years ago I put together the following expect script to perform Open Directory backups under Tiger Server and it's worked well under Leopard Server as well:
#!/usr/bin/expect -f
set date [timestamp -format "%Y-%m-%d"]
set archive_path…

morgant
- 1,470
- 6
- 23
- 33
2
votes
1 answer
Ansible "expect" module with sudo?
I want to run an installer script with Ansible. The installer script prompts for a number of responses and requires to be run with root privileges.
Here is the essence of my Ansible task:
- expect:
become: yes
become_method: sudo
command:…

Mikkel
- 163
- 1
- 2
- 8
2
votes
1 answer
How to use wget in an Expect script?
I first download a file to /root/TRY1/:
#!/usr/bin/expect
cd /root/TRY1/
exec wget --http-user $user --http-password $password $url
Then I want to extract the file:
cd /root/TRY1/
exec bash -c "tar -xzvf /root/TRY1/BigDataProtector*.tgz"
However,…

user375501
- 21
- 2
2
votes
3 answers
password check in bash script calling on expect
Background: I have to copy a file from one server, to over 100 servers in a test environment. once the file is copied, it requires to have the permissions on the file changed/verified. These are all linux servers. most of them have the same password…

2legit2quit
- 171
- 1
- 2
- 10
2
votes
2 answers
Router config export via expect script - username in enable?
I'm working on an Expect script for pulling configuration information from my hosts.
The problem is that some of my hosts (when the enable command is entered) will prompt for both a login and password. This is mostly older HP kit but I've run into…

Tim Brigham
- 15,545
- 10
- 75
- 115
2
votes
1 answer
kill screen session in an expect script
I start my screen connection with a spawn command within an expect script:
spawn screen /dev/...
But I don't know how I can kill the screen when the script is finished

jens freudenau
- 23
- 3
2
votes
1 answer
Expect Script, timeouts and error checking
I was hoping to get a little insight into an expect script that I've written.
Basically we have this expect script to perform an sftp upload, key authentication is not an option, and sftp is the only method supported by our vendor, thus the need for…

Ty Haller
- 21
- 1
- 1
- 2
2
votes
1 answer
run several bash scripts with expect code and leave them running
I have a bunch of several bash scripts that will perform some actions that require user input, therefore I'm using expect with it.
However, I need one to keep running. But if I use expect, the expect command will wait while the script is running and…

Andreas Calvo
- 21
- 1
- 2
1
vote
0 answers
expect, mpd5 and dynamic config loading
I have a FreeBSD server that's connected to WAN using PPPoE. Iva esuccessfully set ip the L2TP and PPTP VPN ontop of this PPPoE WAN connection. The problem is that L2TP needs to call 'set lt2p self ` clause to start listening to the udp/1701 port,…

drookie
- 8,625
- 1
- 19
- 29
1
vote
0 answers
Ansible expect does not pass response to kibana keystore
Ansible expect is not passing ansible variable on first pass. If I make changes and re run the script adding an additional response question then the script seems to work but if I just want to set this up initially first run scenario it doesn't work…

kcomer
- 31
- 1
- 3
1
vote
1 answer
Expect Scripting: Is there a way to default back to a previous spawn_id?
After I scp a file using spawn, the spawn_id, exp8, closes out. gets eof. so, any other commands I run after that, I get this message: an not find channel named "exp8". So I'm assuming that once a spawn occurs, the script defaults to the latest…

Gene
- 15
- 4
1
vote
1 answer
Expect doesn't recognize output on Cisco router
I'm writing a script with expect to configure cisco routers automatically via ssh.
A part of this script is to copy an image into flash if it doesn't exist:
For this expect sends a copy and waits for Destination filename then sends a return.…

SummerRain
- 13
- 2
1
vote
1 answer
SFTP script gets different destination response when run from different directories
I'm baffled by an SFTP shell script and any help would be greatly appreciated. I wrote an sftp script to connect to and upload ACH information to a banking site. The script uses 'expect' to wait for responses from the remote site. The script runs…

Dan P
- 31
- 1
- 2