Questions tagged [expect]
The expect tag has no usage guidance.
80
questions
0
votes
1
answer
333
views
expect usage in bash script or bash command in expect script
I have a script below that works except for the expect portion:
#!/bin/bash
#
invdir=/home/john/inventory
for file in $invdir/$1
do
if [ -z $1 ] || [ -z $2 ]
then
echo "You must enter a ...
0
votes
1
answer
55
views
Script Need to send mail if condition dont match [closed]
looking for your advise.. i have expect script which execute perfectly and save output to a file, filename is 'fileout'.. output from fileout shows like below..
NAME ...
0
votes
1
answer
419
views
Continue statement doesn't work as it should - bash
For the context, i have an infrastructure of multiple machines using ssh.
We connect via ssh as root on the machines without password thank's to the authorized_keys file on each mchine. We are adding ...
1
vote
1
answer
336
views
Using expect to automate Alpine Linux installation in FreeBSD in Bhyve
I am attempting to automate installation of Alpine Linux in vm-bhyve under FreeBSD and expect dies shortly after the boot menu times out and launches the Alpine Linux installation.
#!/usr/bin/env ...
0
votes
1
answer
428
views
Restart services on multiple remote servers securely
I need to write a script so that my colleagues and myself can restart different services on multiple servers. We all connect to the servers with LDAP so i'd like my script to connect our LDAP users to ...
4
votes
1
answer
6k
views
using ansible --ask-become-pass in a variable
I would need to use my --ask-become-pass password in an expect script. Is there any way to use the password entered when starting ansible_playbook in a variable?
Pseudo-code:
# ansible-playbook --...
0
votes
0
answers
225
views
ansible.builtin.expect to automate an installation and having to go thru a license agreement
I am trying to use ansible.builtin.expect to automate an installer. At the beginning of the install, I have to "read" thru the license agreement by hitting the space bar 7 or 8 times. I do ...
0
votes
0
answers
156
views
on expect: need to spawn a python script that fetches a string and send it back
The first script is basically an external lib that I don't want to tamper with.
I already tried the following:
set timeout 100
spawn python long-running-script-with-prompt.py
expect "Type the 6 ...
0
votes
0
answers
104
views
Bash to expect script to add user
Need help Required to convert below bash script in expect script.
#Script to Add User
tail /etc/passwd | cut -d: -f1
read -p 'Please Enter The Username To Add: ' name
echo "$name" > /tmp/...
0
votes
1
answer
145
views
Trim and allign an output of command in expect script
{ echo ' ' ;echo ' IP : ' ;ip route get 8.8.8.8 | cut -d' ' -f7,8 | tr -d 'src' ;echo ' ' ;dmidecode -t bios | grep -iw 'Version' ;echo ' ' ;}
the output of above command mentioned is:
IP :
10.0.0.1
...
0
votes
1
answer
845
views
how to use ping in expect script
Need assistance while i want to ping server if got reply then proceed with script and if no reply go again to previous step where we fetch IP from hosts.txt
#Setting up Variables
set timeout 5 ...
0
votes
0
answers
278
views
Expect Script: First ping the IP stored in hosts.txt file and if got response of ping run script
for below code i want to check if the IP is up via ping and if ip is up run below code eles check next ip from hosts.txt
Edit 2: FYI ill be running script from windows machine
Edit 3:I managed to ...
1
vote
1
answer
1k
views
Merging Expect script and Bash script
This is my expect script for login into a remote server.where i ask user to put password.
#!/usr/bin/expect -f
#Grabbing Password to be used in script further
stty -echo
send_user -- "Enter the ...
0
votes
2
answers
1k
views
shell scripting with expect and a complex command line: no such file or directory
I'm trying to make this work
#!/usr/bin/expect
spawn "(psql blabla \"blabla sql;\" &> /dev/null) && (pg_restore -d xx my_file.sql &> /dev/null)"
expect "Password for user ...
0
votes
0
answers
200
views
I would like to automate the ssh login to an AIX server that hs
I would like to automate the login to an AIX server. I dont have a way to set up ssh keys im on mac so i cant install ssh pass so my only option left would be expect.
#!/usr/bin/expect -f
set ...
5
votes
2
answers
4k
views
How to detect timeouts in an expect script
Consider an expect script that spawns a command and waits for a sequence of events. We use this to test software. I'm trying to always get a failure return value from the script when there is a ...
1
vote
0
answers
193
views
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 ` ...
1
vote
0
answers
696
views
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 ...
-1
votes
1
answer
708
views
kpcli bash script to automate entries
I am trying to create a bash script which uses kpcli in order to automate entries into a kdbx file. While searching over here I found out that you
could use expect and send, however this does not ...
1
vote
1
answer
741
views
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 ...
0
votes
1
answer
319
views
Forwarding access to mysql via ssh tunnel with the help of expect
I have this command that creates a working ssh tunnel for access to MySQL server:
ssh -f test@remotehost -L 127.0.0.1:3306:mysqlhost:3306 -N
Here, remotehost is accessible only via jump host which ...
7
votes
1
answer
8k
views
How to get installed unbuffer on centos?
$ unbuffer
-bash: unbuffer: command not found
Centos 7.x
How to install it by using yum?
yum install unbuffer doesn't work.
0
votes
1
answer
1k
views
How to use SFTP BatchMode inside EXPECT[Shell Script]
I have set of series SFTP commands which needs to run inside expect.
But when i run the below script due to some reasons am not getting any output. Please correct me if am wrong any where inside the ...
1
vote
1
answer
464
views
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 ...
-1
votes
3
answers
2k
views
Linux + how to run the ssh-keygen interactive from bash script [closed]
Please advice how to generate the file id_rsa.pub without answering the questions from "ssh-keygen -t rsa"
my target is to run the ssh-keygen from bash script from postgress USER, and it must run ...
0
votes
0
answers
199
views
Expect is prompting password twice while spawn
spawn ssh -q [email protected]
Password:
Password:
Expect is expecting null before I sent the password.
Debug info
expect: does "" (spawn_id exp6) match glob pattern "yes/no"? no
"Password: "? no
...
0
votes
1
answer
8k
views
Ansible expect not passing response
I am trying to use Ansible with the expect module to join a linux server to a active directory with sssd.
code from the task:
- name: join domain
expect:
command: /bin/bash -c "/usr/sbin/realm ...
2
votes
1
answer
4k
views
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:
...
2
votes
1
answer
1k
views
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 ...
0
votes
1
answer
58
views
Same script, same OS, same installation, failing
So I'm working with RANCID to monitor some switches and I'm using clogin now to test some modifications.
I'm working in two different computers but both of them from the office. Althought they are ...
0
votes
1
answer
3k
views
Expect Scripting Issue Reading From File
I am trying to change the password for a user on a bunch of linux based routers pulling IPs from a list. The iplist.txt is just a list of ips (one per line). This is the code I am trying to use:
#...
5
votes
3
answers
51k
views
Expect script too fast: add a sleep between each line read from a file
I am trying to automate switch commands. It's almost all good, but when the expect script reads each line from the file containing my switch commands (listed line by line), the switch seems to stop ...
0
votes
1
answer
628
views
SSH to ESXi server with Expect immediately closes
I am writing a VM deployment tool that needed to start VMs on an ESXi server. To do this I am using Perl's Expect module to spawn an ssh client to connect to the server and use vim-cmd to manage the ...
1
vote
1
answer
51
views
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 ...
0
votes
4
answers
10k
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 '...
1
vote
1
answer
2k
views
expect script running screen stops working when run by cron
I hope this question is OK for this forum.
I have a device, a modem. I talk to this modem with the linux program "screen" as a terminal program. I invoke it like this "/usr/bin/screen /dev/tty6". I ...
1
vote
2
answers
12k
views
#!/usr/bin/expect not working
This is probably an easy question, however have a simple expect script that I've add the executable bit to that seems to be ignoring the #!/usr/bin/expect interpreter line. Further more, it also ...
2
votes
3
answers
4k
views
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 ...
0
votes
1
answer
1k
views
catch bash script output from expect, expect hangs
I currently use expect to pass password to rsync to copy files across unix servers
test.sh
./expect.sh $password rsync -azvr $username@$host:$file ./$dir
expect.sh
#!/usr/bin/expect -f ...
0
votes
0
answers
53
views
less doesn't work in LXC container
I'm experiencing some trouble running less and expect inside LXC container (whether using console or SSH)
Expect won't work before I won't add an "interact" anywhere in the script, and less doesn't ...
0
votes
1
answer
2k
views
Bash Script - Expect does not send password that ends with $!. Also need improvement to report connection timed out
Update: Password issue is fixed and connection timed out message was fixed too.
Adding \ before $! worked. Example: *password\$!
set passwds { *password\$! @tempP@ss %Test4%}
For connection timed ...
9
votes
2
answers
38k
views
Expect script error send: Spawn id exp4 not open while executing
I'm trying to run this script but having different errors when modified. Here is the code and the output. Please help.
Updates at the end of the post with debug info
#!/bin/bash
(( $# != 1 )...
0
votes
1
answer
143
views
How to distribute root files with expect?
I've recently learned how great expect is, now that I'm suddenly responsible for managing 150 VMs. I've been using it to distribute config files to remote servers, but there's got to be a better way ...
0
votes
1
answer
626
views
SELinux problems running Expect script from fail2ban
I have an Expect script that works fine if I run it manually, but fails when run as an action from Fail2ban. The error message is as follows:
spawn /usr/bin/telnet 192.168.242.1
The system has no ...
8
votes
1
answer
28k
views
Ansible ssh as user and execute has root (expect like)
I have to administer an important number of hosts where there is only one user able to access from SSH (let's call him foo) and then have to login as root to execute privilegied commands.
Foo user ...
5
votes
3
answers
4k
views
How to keep script from swallowing all of stdin?
I have a script that reads from a pipe in a loop and runs an expect script and a normal shell script in the loop. Both scripts run ssh to another server to grab a piece of data. For example:
cat /...
2
votes
2
answers
936
views
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 ...
1
vote
1
answer
3k
views
expect: how to use expect scripts from within a bash subroutine
I want to write a login script in expect. But I want this to be reused in different other scripts. I want to make all the login commands part of a bash subroutine. ie instead of
expect_login.sh
#!/...
1
vote
2
answers
2k
views
Error while installing php extension 'expect'
I got some serious error while installing expect extension in PHP.
I ran sudo pecl install channel://pecl.php.net/expect-0.3.1
I got error like this while running make,
running: make
/bin/bash /tmp/...
1
vote
1
answer
2k
views
expect script works fine standalone not from bash script
I am running a expect script,which login to a server check if iptables running and return the log file of the status. There is a hostfile also given with server list and password, expect is being ...